You are here: Re: Multiple records in one row « MsSQL Server « IT news, forums, messages
Re: Multiple records in one row

Posted by Erland Sommarskog on 09/10/07 21:23

Ray (csdeveloper06@gmail.com) writes:
> The number of products will be determined by the "items" table. Here
> is the query as I have it before any rotating and such. The select *
> is for ease of use while in development.
>
> select permutations.location_key, permutations.location_name,
> permutations.item, permutations.Currency_Code, pp.price --
> permutations.*, pp.*
> from
> (select * from item
> cross join location) permutations
> left join productPrice pp
> on permutations.item_key = pp.item_key and
> permutations.location_key = pp.location_key
> order by permutations.location_key, permutations.Item_key

And the contents of "items" may change depending on the mood of the
day?

Looks like you are in for a dynamic pivot, which you can't do in a single
SQL statement; you need to use dynamic SQL. Or a third-party product like
RAC, www.rac4sql.net.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

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

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