|
Home > Archive > MySQL ODBC Connector > September 2005 > colum totals
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Tony Leake 2005-09-16, 7:23 am |
| Hi,
I'm sure I read somewhere about a new function that would give the
totals of all columns, ie if i have 2 cols, numberOfOrders valueOfOrders
for a range of dates i can get something like the following
Date numberOfOrders valueOfOrders
01-09 4 20.00
02-09 6 100.00
total 10 120.00
could someone point me to this in the manual please as I can't seem to
find it. Or did i just imagine it anyway?
thanks
tony
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
| |
| Mark Leith 2005-09-16, 9:23 am |
| You can achieve this with the WITH ROLLUP option of GROUP BY. Although you
would probably have to perform a trick on the "date" column to have the NULL
value that WITH ROLLUP would return to return as "total" - i.e
IFNULL(date,'Total')
as a quick (and dirty) example, as this doesn't work
too well on statements that have multiple GROUP BY columns ;)
You can read more about WITH ROLLUP here:
http://dev.mysql.com/doc/mysql/en/g...-modifiers.html
Mark Leith
> -----Original Message-----
> From: Tony Leake [mailto:tony@thx-trade.com]
> Sent: 16 September 2005 13:19
> To: mysql@lists.mysql.com
> Subject: colum totals
>
> Hi,
>
> I'm sure I read somewhere about a new function that would
> give the totals of all columns, ie if i have 2 cols,
> numberOfOrders valueOfOrders for a range of dates i can get
> something like the following
>
>
> Date numberOfOrders valueOfOrders
> 01-09 4 20.00
> 02-09 6 100.00
> total 10 120.00
>
>
> could someone point me to this in the manual please as I
> can't seem to find it. Or did i just imagine it anyway?
>
> thanks
>
> tony
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=...ool-tools.co.uk
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.11.0/103 - Release
> Date: 15/09/2005
>
>
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.0/103 - Release Date: 15/09/2005
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
| |
|
|
|
|
|