2 gaoandshan Gaoandshan 于 2014.03.12 14:29 提问

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查询的就是一个时间 ???

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!