sql server 2008 - Different Items in single row to get the total amount of that order -
i have order table in insert items customer placed in order in single row.like
table_order
( od_id
primary key auto incrementd)
od_id cust_name quantity of 101(int) quantity of 102 quantity of 103 ----- ------- -------------------- --------------- -------------- 1 john 5 4 7 2 kim 4 3 2
another table of price like
table_ price prod_id price (money) ------- ------ 101 5.2 102 2.5 103 3.5
now want total amount of specific order placed customer. problem if use differnt rows different item order id changed , if use single row how calculate total price can put jst single prod_id colum.
kindly guide me , send solutions
regards
i see table design violates of design values starting no foreign key between tables.
but worst case solution problem here:
select ( q101*price101.price+q102*price102.price) 'total price' (select p.id, q101, price `order`, price p p.id=101) price101, (select p.id, q102, price `order`, price p p.id=102) price102, (select p.id, q103, price `order`, price p p.id=103) price103
i trying build tables connect 2 of tables , query based on that.
but gets tedious number of products grow. suggest think of design alternative.
note: have chosen column names this: quantity of 101 = q101
Comments
Post a Comment