[thelist] [SQL] one query to retrieve multiple totals

Paul Bennett paul at teltest.com
Fri Mar 28 03:29:18 CST 2003


My curent sql knowledge doesn't go much further than select, insert,
update, delete, but I'm willing to learn - really I am!
I am using MySQL version 3.23.54

I have a table which holds records of timesheet entries like so
"projectTime" table
--------------------------------
userId => numeric id of user
hours =>number of hours spent on task
taskId =>task they spent time working on
projectId => project that task belongs to
----------------------------------
I now want to produce monthly reports showing (in this case) a breakdown
of how many hours (total) a user spent on each project.
EG; I want the results => userId, projectId, hours (total) for each project.
I can do this with server side code by looping through results and doing
subqueries for each project, but a nagging voice (I do hear them from
time to time) is telling me that there must be an easier way to query
the db and get the results returned in one hit.

-- 
------------------------------
	Paul Bennett						
	Internet Developer				
	Teltest Electronic Design		
------------------------------			
Email: paul at teltest.com				
Phone: 64 4 237 4557					
Web: http://www.teltest.com		
Wap: http://wap.teltest.com			





More information about the thelist mailing list