Subject | Re: [firebird-support] Advice on following SQL string |
---|---|
Author | Alan J Davies |
Post date | 2011-06-21T19:22:56Z |
Not certain from the way your details are outlined what you need, but
something along these lines:
select TRADEDATE, BARCODENUMBER, POSDESCRIPTION, SALEGROUP, sum(QTYSOLD),
sum(LINETOTAL)
group by TRADEDATE, BARCODENUMBER, POSDESCRIPTION, SALEGROUP
That will give you "summary of all the sales for each item PER DAY"
On a weekly basis you will need to add a where clause for the relevant
begin/end dates
HTH Alan
Alan J Davies
Aldis
something along these lines:
select TRADEDATE, BARCODENUMBER, POSDESCRIPTION, SALEGROUP, sum(QTYSOLD),
sum(LINETOTAL)
group by TRADEDATE, BARCODENUMBER, POSDESCRIPTION, SALEGROUP
That will give you "summary of all the sales for each item PER DAY"
On a weekly basis you will need to add a where clause for the relevant
begin/end dates
HTH Alan
Alan J Davies
Aldis
On 21/06/2011 19:32, Andrew Gable wrote:
> Hi all,
>
> I have the following table in my database
>
> SALEHISTORY
>
> TRADEDATE VARCHAR(20);
>
> BARCODENUMBER VARCHAR(13);
>
> POSDESCRIPTION VARCHAR(20);
>
> QTYSOLD VARCHAR(20);
>
> LINETOTAL VARCHAR(20);
>
> SALEGROUP VARCHAR(4);
>
> What I am trying to do is get a weekly summary of all the sales for each
> item PER DAY
>
> Example
>
> TRADEDATE BARCODENUMBER POSDESCRIPTION QTYSOLD
> LINETOTAL SALEGROUP
>
> 2011/06/12 401440 M&M PEANUT BUTTER
> 1 0.99 0016
>
> 2011/06/12 02800082226 LAFFY TAFFY - CHERRY
> 1 0.59 0014
>
> 2011/06/14 401440 M&M PEANUT BUTTER
> 2 1.98 0016
>
> 2011/06/14 782640 A & W CREAM SODA
> 1 0.99 0001
>
> The report should look like
>
> BARCODENUMBER POSDESCRIPTION DATE
>
> 12/06/2011 14/06/2011
>
> 401440 M&M PEANUT BUTTER
> 1 2
>
> 02800082226 LAFFY TAFFY - CHERRY
> 1
>
> 782640 A & W CREAM SODA
> 1
>
> I have NO IDEA how to write the SQL Statement to deal with this (at the
> moment i am looping through the database and adding each number at a
>
> Time and this still does not work correctly)
>
> Any advice or even some sample SQL statements would be most welcome
>
> Andy
>
> [Non-text portions of this message have been removed]
>
>
> ------------------------------------------------------------------------
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 10.0.1382 / Virus Database: 1513/3717 - Release Date: 06/21/11
>