這裏是我的表即book_master有以下詳細怎樣用DATEDIFF函數兩個日期之間diffrence動態使用SQL Server 2008
id book_nmae book_cost publish_date
6 maths 150.0000 1992-08-06
7 science 120.0000 1992-08-07
8 gujrati 100.0000 1992-08-08
9 english 105.0000 1992-08-09
10 social study 100.0000 1992-08-10
在這裏,我想出版日期1992年8月6日和1992之間diffrence 08-07使用book_name列。
我曾嘗試以下條件爲sql
SELECT DATEDIFF(DAY,book_master.publish_date,book_master.publish_date)
from book_master where book_name in('science','maths')
select DATEDIFF(DAY,book_master.publish_date.book_name('maths'),book_master.publish_date.book_name('science'))
from book_master
問候 rajdeep帕爾馬
上'(BOOK_NAME)的唯一索引'會有所幫助。 –