Efficient SQL
Posted: Fri Jul 21, 2006 11:03 am
I have been thinking about an efficient way of retrieving some data. Basically, I need to display a table like this:
Each cell will contain a number of logins of a certain user (for each week day, total and average). The login table that I need to generate this report from looks like this (LoginDate is an int, generated by PHP's time()):
So basically each record in the table is a login of a certain user for a certain date. Now I was wondering what would be an efficient query to generate the report?
Code: Select all
Mon Tue Wed Thu Fri Sat Sun Total Avg
User 1 - - - - - - - - -
User 2 - - - - - - - - -
User 3 - - - - - - - - -
User 4 - - - - - - - - -
User 5 - - - - - - - - -Code: Select all
-----------------------
ID UserID LoginDate
1 2 1111111
2 30 1111111
3 95 1111111
-----------------------