如果我正在执行此SQLlite命令,我坚持跟随错误:
Error: near "FROM": syntax error
我查询了几次查询代码,但我无法找到错误。
有人可以告诉我我的代码有什么问题吗?
感谢您的帮助。
SQL查询:
SELECT d.date AS DATE,
IFNULL(DIALS_CNT, 0) AS DIALS_CNT,
IFNULL(APPT_CNT, 0) AS APPT_CNT,
IFNULL(CONVERS_CNT, 0) AS CONVERS_CNT,
FROM
(SELECT DATE('2014-01-01', '+' || (t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) || ' days') date
FROM
(SELECT 0 i
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9) t0,
(SELECT 0 i
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9) t1,
(SELECT 0 i
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9) t2,
(SELECT 0 i
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9) t3,
(SELECT 0 i
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9) t4) d
LEFT JOIN
(SELECT substr(m.date, 1, 10) AS my_date,
COUNT(m.ID) AS 'DIALS_CNT',
(SELECT COUNT(*)
FROM dialed_calls subq
WHERE subq.call_result = 'APPT'
AND substr(m.date, 1, 10) = substr(subq.DATE, 1, 10)) AS 'APPT',
(SELECT COUNT(*)
FROM dialed_calls subq
WHERE subq.call_result = 'CONV_NO_APPT'
AND substr(m.date, 1, 10) = substr(subq.DATE, 1, 10)) AS 'CONV_NO_APPT',
(SELECT COUNT(*)
FROM dialed_calls subq
WHERE subq.call_result = 'CANNOT_REACH'
AND substr(m.date, 1, 10) = substr(subq.DATE, 1, 10)) AS 'CANNOT_REACH'
FROM dialed_calls m
GROUP BY my_date) t ON d.date = t.my_date
WHERE d.date BETWEEN '2014-09-30' AND '2014-09-20'
ORDER BY d.date;
答案 0 :(得分:2)
一个简单的拼写错误;
IFNULL(CONVERS_CNT, 0) AS CONVERS_CNT, <-- extraneous comma
FROM