2

刚刚学习 SQLite ......我运行这个查询:

select guests.[GUEST_NAME],guests.[GUEST_SURNAME],guest_data.[START_DATE],guest_data.[END_DATE]
from guests
INNER JOIN guest_data
ON guests.guest_id=Guest_data.guest_id
order by  guests.[GUEST_SURNAME] ASC

这工作正常,但我需要学习:如何在 start_date,end_date 之间获得额外字段作为 DAYS 作为 datediff ?我尝试添加:

 select guests.[GUEST_NAME],guests.[GUEST_SURNAME],guest_data.[START_DATE],guest_data.[END_DATE],DAYS as Daysbetween(guest_data.start_date,guest_data.end_date)

但它不起作用。另外这个查询如何用delphi编写?

4

1 回答 1

3
select guests.[GUEST_NAME],guests.[GUEST_SURNAME],guest_data.[START_DATE],guest_data.[END_DATE],
julianday(guest_data.end_date) - julianday(guest_data.start_date) AS DAYS_INTERVAL
from guests
INNER JOIN guest_data
ON guests.guest_id=Guest_data.guest_id
order by  guests.[GUEST_SURNAME] ASC

请尝试这种语法结构并让我们发布。您的天数间隔应作为名为“DAYS_INTERVAL”的结果集中的单独列返回

于 2013-10-20T13:08:28.863 回答