问题描述
- SQl 不同表达形式查询结果不一样
-
语句1:select (select Paymentdaystr from tss_POPayDateterm where POId=16) from tss_POInfomation where id=16语句2: select DATEDIFF(day,CompgoosDate,CAST(DATEPART(YEAR,CompgoosDate) as nvarchar(10))+'-'+CAST(DATEPART(month,CompgoosDate)+0 as nvarchar(10))+'-'+CAST(27 as nvarchar(10)))/DATEDIFF(day,CompInvoiceDate,CAST(DATEPART(YEAR,CompInvoiceDate) as nvarchar(10))+'-'+CAST(DATEPART(month,CompInvoiceDate)+0 as nvarchar(10))+'-'+CAST(27 as nvarchar(10))) from tss_POInfomation where id=16
为什么查询的结果不一样select Paymentdaystr from tss_POPayDateterm where POId=16 查询的结果是等于DATEDIFF(day,CompgoosDate,CAST(DATEPART(YEAR,CompgoosDate) as nvarchar(10))+'-'+CAST(DATEPART(month,CompgoosDate)+0 as nvarchar(10))+'-'+CAST(27 as nvarchar(10)))/DATEDIFF(day,CompInvoiceDate,CAST(DATEPART(YEAR,CompInvoiceDate) as nvarchar(10))+'-'+CAST(DATEPART(month,CompInvoiceDate)+0 as nvarchar(10))+'-'+CAST(27 as nvarchar
(10)))为什么语句1查询的结果就是select Paymentdaystr from tss_POPayDateterm where POId=16查询的结果
语句2查询的就是一个时间 ???