|
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]
|