Too many hours - brain not working.....
Hey y'all - I have been at this too long today - this is driving me nuts! Table: Date (y-m-d),amount (decimal),dealercode I am looking for a query that will give me the sum of each of the distinct dealercodes for a specific date range. Something to the effect of: Select (distinct dealercode),sum(amount) as total where date between 'this' and 'that' The trouble that I am running into is that I cannot seem to get that done in one query - splitting it up into 2 is easy enough - do the distinct dealercode, then loop through those to do the sum between date query - but ideally I would like to do it in one query. If this is possible to do - how? TIA! -- Cheers Mike Morton * * Tel: 905-465-1263 * Email: [EMAIL PROTECTED] * Indeed, it would not be an exaggeration to describe the history of the computer industry for the past decade as a massive effort to keep up with Apple. - Byte Magazine Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes. -- NullGrey -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Too many hours - brain not working.....
Mike Morton said: Hey y'all - I have been at this too long today - this is driving me nuts! Table: Date (y-m-d),amount (decimal),dealercode I am looking for a query that will give me the sum of each of the distinct dealercodes for a specific date range. Something to the effect of: Select (distinct dealercode),sum(amount) as total where date between 'this' and 'that' The trouble that I am running into is that I cannot seem to get that done in one query - splitting it up into 2 is easy enough - do the distinct dealercode, then loop through those to do the sum between date query - but ideally I would like to do it in one query. If this is possible to do - how? TIA! -- Cheers Mike Morton * * Tel: 905-465-1263 * Email: [EMAIL PROTECTED] * Indeed, it would not be an exaggeration to describe the history of the computer industry for the past decade as a massive effort to keep up with Apple. - Byte Magazine Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes. -- NullGrey Welcome to 'Group By' Table: Date (y-m-d),amount (decimal),dealercode select sum(amount),dealercode from table where date 'date1' and date 'date2' group by dealercode William R. Mussatto, Senior Systems Engineer Ph. 909-920-9154 ext. 27 FAX. 909-608-7061 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Too many hours - brain not working.....
Thanks to everyone that replied on and off list - off to the group by docs ;) On 8/28/03 5:09 PM, William R. Mussatto [EMAIL PROTECTED] wrote: Mike Morton said: Hey y'all - I have been at this too long today - this is driving me nuts! Table: Date (y-m-d),amount (decimal),dealercode I am looking for a query that will give me the sum of each of the distinct dealercodes for a specific date range. Something to the effect of: Select (distinct dealercode),sum(amount) as total where date between 'this' and 'that' The trouble that I am running into is that I cannot seem to get that done in one query - splitting it up into 2 is easy enough - do the distinct dealercode, then loop through those to do the sum between date query - but ideally I would like to do it in one query. If this is possible to do - how? TIA! -- Cheers Mike Morton * * Tel: 905-465-1263 * Email: [EMAIL PROTECTED] * Indeed, it would not be an exaggeration to describe the history of the computer industry for the past decade as a massive effort to keep up with Apple. - Byte Magazine Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes. -- NullGrey Welcome to 'Group By' Table: Date (y-m-d),amount (decimal),dealercode select sum(amount),dealercode from table where date 'date1' and date 'date2' group by dealercode William R. Mussatto, Senior Systems Engineer Ph. 909-920-9154 ext. 27 FAX. 909-608-7061 -- Cheers Mike Morton * * Tel: 905-465-1263 * Email: [EMAIL PROTECTED] * Indeed, it would not be an exaggeration to describe the history of the computer industry for the past decade as a massive effort to keep up with Apple. - Byte Magazine Given infinite time, 100 monkeys could type out the complete works of Shakespeare. Win 98 source code? Eight monkeys, five minutes. -- NullGrey -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]