There is a table named images in mediastore database in android, the images table has a column named timetaken which represents created time of the image, and it is in milliseconds unit.
Now I have a demand that I want to group the images by created day(not the time), and count images of each day, so I have try this query:
SELECT datetaken/86400000*86400000 as dateT, count(dateT) as imageSumInDate
FROM images
WHERE (1 = 1 )
group by (dateT)
ORDER BY dateT DESC
Unfortunately, it comes out a error:
android.database.sqlite.SQLiteException: no such column: dateT (code 1)
Then I ask someone else for the problem, and he give a sub-query style like this below:
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
This may be correct, but I can't use this sub-query in ContentResolver's query method. ContentResolver may only support the query like this style:
select ____ from table where ______ order by____
Is there any trick to help me fit the ContentResolver's query style?
Any help would be really appreciated!