You are here: SQL Query Question « MsSQL Server « IT news, forums, messages
SQL Query Question

Posted by commerce on 04/12/06 21:43

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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация