List:General Discussion« Previous MessageNext Message »
From:Bill Adams Date:October 29 2005 1:24am
Subject:RE: 'GROUP BY' behavior
View as plain text  
 
Shawn,

That's a very reasonable answer.  Thanks for pointing me to the
examples.  This one addresses the second question:
http://dev.mysql.com/doc/refman/4.1/en/example-maximum-column-group-row.
html .  There is no example answering both questions in one query.

Regards,
Bill

________________________________

	From: SGreen@stripped [mailto:SGreen@stripped] 
	Sent: Friday, October 28, 2005 11:14 AM
	I do not think you are posing a single-statment question to the
database (I count subqueries as second statements). 
	You would like to find the averages of (used/allocated) and
(used) for all (qtreename,hostname) pairs. That's one question. 
	
	The second question is to return the row with the greatest
timestamp for each (qtreename,hostname) pair along with the averages
calculated in the first question. 
	
	To find the answer your first question is a simple GROUP BY
query. To find the answer to your second takes a max-of-group-pattern
query: 
	http://dev.mysql.com/doc/refman/4.1/en/examples.html 
	
	If it were me, I would use a temporary table for each stage and
combine them to form the final report. If you need more help, just come
back. 
	
	Shawn Green
	Database Administrator
	Unimin Corporation - Spruce Pine 
	 

Thread
'GROUP BY' behaviorBill Adams28 Oct
  • Re: 'GROUP BY' behaviorSGreen28 Oct
RE: 'GROUP BY' behaviorBill Adams29 Oct
  • Re: 'GROUP BY' behaviorMichael Stassen31 Oct