Hi,
I want to merge data from multi rows to one row.
For example,
I have two table one is 'ORDER' and one is 'ORDERDETAIL'.
What I want to do is when I want to get orders against 'user'...
I want to get 'ORDER' table INNER JOINED with 'ORDERDETAIL' but with TOTAL added and merged in a sigle row instead of multiple rows.
I want to generate this function in Stored Procedure in SQL 2005.
Can you help me about this?
1. ORDERDETAIL Table
OrderID......Pr ice.....Quantit y
A.............. ....10......... ...1
A.............. ....14......... ...2
B.............. ....15......... ...3
C.............. ....20......... ...4
C.............. ....23......... ...5
C.............. ....24......... ...6
2. RESULT TABLE (Output)
OrderID........ .Total
A.............. ....(10 * 1) + (14 * 2)
B.............. ....(15 * 3)
C.............. ....(20*4) + (23*5) + (24*6)
I want to merge data from multi rows to one row.
For example,
I have two table one is 'ORDER' and one is 'ORDERDETAIL'.
What I want to do is when I want to get orders against 'user'...
I want to get 'ORDER' table INNER JOINED with 'ORDERDETAIL' but with TOTAL added and merged in a sigle row instead of multiple rows.
I want to generate this function in Stored Procedure in SQL 2005.
Can you help me about this?
1. ORDERDETAIL Table
OrderID......Pr ice.....Quantit y
A.............. ....10......... ...1
A.............. ....14......... ...2
B.............. ....15......... ...3
C.............. ....20......... ...4
C.............. ....23......... ...5
C.............. ....24......... ...6
2. RESULT TABLE (Output)
OrderID........ .Total
A.............. ....(10 * 1) + (14 * 2)
B.............. ....(15 * 3)
C.............. ....(20*4) + (23*5) + (24*6)
Comment