Can't you do something with SUM() to get the results, possibly in
coordination with GROUP BY?
--Nathan
On 2001.03.01 23:49:28 -0500 Thalis A. Kalfigopoulos wrote:
> Now that I notice more closely the numbers, my answer was obviously wrong
> with regard to the 3rd column :o)
>
> Very interesting question...but I doubt there is a SQL way to do that.
> Looking fwd to what the rest will sugest.
>
> cheers,
> thalis
>
>
> On Fri, 2 Mar 2001, Richard Vibert wrote:
>
> > Hi,
> > At 01:52 pm 2/03/2001, Thalis A. Kalfigopoulos wrote:
> > >On Fri, 2 Mar 2001, Richard Vibert wrote:
> > >
> > > > Hi,
> > > >
> > > > I having trouble working out how to get a result set similar to the
> > > > following where I select from a table with Date & Sales column.
> > > >
> > > > My specific question is can I have a column that accumulates
> values, if so
> > > > could I have some guidance on how to express this in a select
> statement
> > > please.
> > > >
> > > >
> > > > +----------+-----------+-----------+
> > > > | Month | Sales | Cum Sales |
> > > > +----------+-----------+-----------+
> > > > | Jan | 1000 | 1000 |
> > > > | Feb | 1500 | 2500 |
> > > > | Mar | 1200 | 3700 |
> > > > | April | 1400 | 5100 |
> > > > +----------+-----------+-----------+
> > > >
> > > > Many thanks in advance.
> > > >
> > > > Richard
> > >
> > >I assume the query should be like:
> > >
> > >select MONTHNAME(date_col) as Month,count(sales_amount) as
> > >Sales,sum(sales_amount) as Cum_sales from lala_table group by
> > >MONTHNAME(date_col);
> > >
> > >regards,
> > >thalis
> >
> > Thanks for your reply.
> >
> > This is not quite what I'm after. Count(sales) gives me the number of
> sales
> > transactions.
> >
> > The first two cols I write as monthname(date_col) as Month, sum(sales)
> as Sales
> >
> > It's the next column that's got me. That needs to be a "Running total"
> if
> > you like.
> >
> > Richard
> > =======================================
> > Richard Vibert
> > [EMAIL PROTECTED]
> > Tatura Mitre10
> > =======================================
> >
> >
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
--
Nathan Clemons <[EMAIL PROTECTED]> 978-635-5300 ext 123
Linux Systems Administrator IRC: etrnl ICQ: 2810688 AIM: StormeRidr
O | S | D | N, 50 Nagog Park, Acton, MA 01720
http://www.osdn.com/ Open Source Development Network
Nextel: 978-423-0165 [EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php