I'm trying to aggregate some data, order it by a specific column, then compare the same data with another time period (e.g. the last week).
An example would be, websites with the most hits this week:
url total hits
www.a.com 10,000
www.b.com 9,0000
www.e.com 5,000
This is ordered by hits, but I'd like to get the hits for the same urls, but over a different time period e.g.:
url total-hits total-hits (last week)
www.a.com 10,000 8,000
www.b.com 9,0000 6,000
www.e.com 5,000 6,000
The table layout for this data is a list of page-hits e.g.:
hit_table:
id timestamp url
1 1426470088 www.a.com
1 1426470000 www.b.com
1 1426468015 www.c.com
1 1426467000 www.b.com
....
Is it possible to do this in a single SQL query, or do I need to have 2 separate queries for this?