SQL Query Question
- From: commerce@xxxxxxxxxxxxxx
- Date: 12 Apr 2006 11:43:22 -0700
Hi all,
I am trying to achieve the following:
Table A has a structure like this:
TransactionNumber (autonumber PK)
Quantity
ProductTypeID (let's say this can have the value 1,2, or 3)
Date
I want to query this data to produce a data structure where each row
has a date (I will get this from a temp table of all dates in my
desired range), then the SUM of any rows containing that date, with
each of the three product types being a column.
So an example row in the resultset would look like:
April 1, 2006;877;155;5
...calculated from the database rows:
188;577;1;April 1, 2006
194;155;2;April 1, 2006
199;5;3;April 1, 2006
204;300;1;April 1, 2006
I do have a solution but it is not very elegant and I am wondering what
others may make of the problem. Is it possible to do this using SQL
only?
.
- Follow-Ups:
- Re: SQL Query Question
- From: --CELKO--
- Re: SQL Query Question
- From: markc600
- Re: SQL Query Question
- Prev by Date: Re: Smalldatetime comparisons with non-clustered index
- Next by Date: Re: rights issues with linked server
- Previous by thread: insert into temp table based on if condition
- Next by thread: Re: SQL Query Question
- Index(es):