在android里写了如下一条语句:
SELECT datetaken/86400000*86400000 as dateT, count(dateT) as imageSumInDate FROM images WHERE (1 = 1 ) group by (dateT) ORDER BY dateT DESC
先将datetaken列运算了一下然后将运算结果起了个别名叫dateT,结果计数时报错说没有dateT这一列,
android.database.sqlite.SQLiteException: no such column: dateT (code 1)
这里要对别名dateT计数应该怎么办?
------解决方案--------------------
SELECT datetaken/86400000*86400000 as dateT, count(dateT) as imageSumInDate FROM images WHERE (1 = 1 ) group by (datetaken/86400000*86400000) ORDER BY dateT DESC
------解决方案--------------------
SELECT datetaken/86400000*86400000 as dateT, count(datetaken/86400000*86400000) as imageSumInDate FROM images WHERE (1 = 1 ) group by (datetaken/86400000*86400000) ORDER BY dateT DESC
------解决方案--------------------
用子查询
select dateT,COUNT(dateT) as imageSumInDate
from (SELECT datetaken/86400000*86400000 as dateT FROM images)t
WHERE (1 = 1 )
group by (dateT) ORDER BY dateT DESC