Aggregate Query

2011-11-18 Thread Nigel Peck
Hi all, Could do with some help please. I have a query that grabs details of items that have been ordered from an ecommerce site. Order details are in "tracking" and ordered items in "trackitem". The query works fine and generates a row for each item, including bits of info retrieved from

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-25 Thread Hal�sz S�ndor
2011/10/24 16:31 -0700, Daevid Vincent WHERE cs.customer_id = 7 GROUP BY customer_id Well, the latter line is now redundant. How will you make the '7' into a parameter? -- MySQL General Mailing List For list archives: http://l

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
October 24, 2011 4:06 PM > To: [email protected] > Subject: RE: Within-group aggregate query help please - customers and latest > subscription row > > A kind (and shy) soul replied to me off list and suggested this solution, > however, > this takes 28 seconds (that's f

RE: Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
- > From: Daevid Vincent [mailto:[email protected]] > Sent: Monday, October 24, 2011 1:46 PM > To: [email protected] > Subject: Within-group aggregate query help please - customers and latest > subscription row > > I know this is a common problem, and I've been struggling

Within-group aggregate query help please - customers and latest subscription row

2011-10-24 Thread Daevid Vincent
I know this is a common problem, and I've been struggling with it for a full day now but I can't get it. I also tried a few sites for examples: http://www.artfulsoftware.com/infotree/queries.php#101 http://forums.devarticles.com/general-sql-development-47/select-max-datetime -problem-10210.html

RE: Updating two fields from an aggregate query

2006-09-26 Thread Robert DiFalco
: Tuesday, September 26, 2006 7:15 AM To: Robert DiFalco Cc: [email protected] Subject: Re: Updating two fields from an aggregate query Robert, you might give "insert ... select ... on duplicate key update" a try: http://dev.mysql.com/doc/refman/5.0/en/insert-select.html something

Re: RE: Updating two fields from an aggregate query

2006-09-26 Thread Dan Buettner
L PROTECTED] Sent: Tuesday, September 26, 2006 7:15 AM To: Robert DiFalco Cc: [email protected] Subject: Re: Updating two fields from an aggregate query Robert, you might give "insert ... select ... on duplicate key update" a try: http://dev.mysql.com/doc/refman/5.0/en/insert-select.html som

Updating two fields from an aggregate query

2006-09-26 Thread Robert DiFalco
I have two tables that are related: Parent LONG id LONG childCount LONG maxChildAge ... Child LONG parentId LONG age ... There can be thousands of parents and millions of children, that is why I have denormalized "childCount" and "maxChildAge". The values are too expensive t

Re: Updating two fields from an aggregate query

2006-09-26 Thread Dan Buettner
Robert, you might give "insert ... select ... on duplicate key update" a try: http://dev.mysql.com/doc/refman/5.0/en/insert-select.html something like this (untested): INSERT INTO parent (id, maxChildAge, childCount) SELECT parentid, MAX(age) as maxAge, COUNT(*) as ct FROM child WHERE parentid I

how to use row total in aggregate query ?

2005-04-27 Thread Graham Anderson
I have a query: I am trying to get a percentage of the total for each city SELECT userLog.city,userLog.region, COUNT(*), /* Count(userLog.id) is always 1 was hoping to get the total row returned */ COUNT(*)/COUNT(userLog.id), media.name,artist.name FROM userLog,media,artist WHERE userLog.medi

Re: Help with aggregate query

2001-11-12 Thread John Morrissey
On Mon, Nov 12, 2001 at 11:14:21AM -0500, Johnson, Gregert wrote: % SELECT SUM(d.AcctSessionTime) + IFNULL(m.Minutes, 0) % FROM detail d LEFT OUTER JOIN monthly_usage m ON d.UserName = m.UserName % WHERE d.UserName = 'foo'; % % Or, to summarize for all users: % % SELECT d.UserName as user, SUM(d

RE: Help with aggregate query

2001-11-12 Thread Johnson, Gregert
Subject:Help with aggregate query I'm logging RADIUS detail records to a MySQL database. Currently, I crunch the the detail table (containing individual records) once a month into another table that contains aggregate usage

Help with aggregate query

2001-11-12 Thread John Morrissey
I'm logging RADIUS detail records to a MySQL database. Currently, I crunch the the detail table (containing individual records) once a month into another table that contains aggregate usage (monthly_usage). CREATE TABLE monthly_usage ( UserName varchar(32) NOT NULL, Realm varchar(64) NOT NULL