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]

 

Author colum totals
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

Tony Leake

2005-09-16, 11:23 am

On Fri, 2005-09-16 at 14:02 +0100, Mark Leith wrote:

> http://dev.mysql.com/doc/mysql/en/g...-modifiers.html
>


perfect, thank you.

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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com