I am having a mental fart...
I have two tables:
DECLARE @.store_options TABLE(store_option_id INT IDENTITY(1,1), store_id INT)
DECLARE @.vendor_options TABLE(vendor_option_id INT IDENTITY(1,1), store_option_id INT, item_id INT, vendor_id INT, price NUMERIC(18,4))
I populate the first table with a litst of stores that offer all desired items.
I populate the second table with a list of vendors, the item is, and cost avaiable at each of the stores in the first table.
What I would like is to output all possible the store and vendor combos ordered by combined price.
So, for instance, I have 3 products, A B and C. Store X has A and B by vendor G, and A B and C by vendor H. I want the output to have all iterations of (Store, Product, Vendor, Price) grouped in order of total price. So...
X A G
X B G
X C H
X A G
X B H
X C H
X A H
X B G
X C H
X A H
X B H
X C H
ordered by each group's combined price.
For some reason, I can't get this straight in my head. Must need more coffee.No feedback here?
Tuesday, February 14, 2012
Cross Join iteration problem...
Labels:
cross,
database,
declare,
fart,
identity,
int,
iteration,
mental,
microsoft,
mysql,
oracle,
server,
sql,
store_id,
store_option_id,
store_options,
table,
tablesdeclare,
vendor_options
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment