hi
i need help for write query
According to the picture below, I have 3 tables
Now I want to take data from three tables and display it in ascending order in terms of day, month and year
All dates are stored in the original database as a tick (datetime.now)
I wrote this code but it is not my desired result
thanks
i need help for write query
According to the picture below, I have 3 tables
Now I want to take data from three tables and display it in ascending order in terms of day, month and year
All dates are stored in the original database as a tick (datetime.now)
I wrote this code but it is not my desired result
B4X:
SELECT 'tb1' as tp,date,
strftime('%Y', date / 1000, 'unixepoch') as year,
strftime('%m', date / 1000, 'unixepoch') as month ,
strftime('%d', date / 1000, 'unixepoch') as day ,
SUM( value ) AS total FROM tb1
GROUP BY year,month,day
UNION
SELECT 'tb2' as tp,date,
strftime('%Y', date / 1000, 'unixepoch') as year,
strftime('%m', date / 1000, 'unixepoch') as month ,
strftime('%d', date / 1000, 'unixepoch') as day ,
SUM( value ) AS total FROM tb2
GROUP BY year,month,day
UNION
SELECT 'tb3' as tp,date,
strftime('%Y', date / 1000, 'unixepoch') as year,
strftime('%m', date / 1000, 'unixepoch') as month ,
strftime('%d', date / 1000, 'unixepoch') as day ,
SUM( value ) AS total FROM tb3
GROUP BY year,month,day
ORDER BY date asc
thanks