Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-13 : 22:05:59
Sanjay writes "I have a table trnStock which maintains the incoming and outgoing stock.

fields name

pk_stock_id
qty
mode

if Mode is 'A' then it is incoming stock or Received Qty if it is 'S' then it will be outgoing stock or Despatched Stock.
I want a query which give me a structure like this


pk_stock_id  Received_Qty Despatched_Qty

e.g
if I have these values in my table
pk_stock_id Qty Mode

1 100 'A'
1 50 'A'
1 25 'S'
1 75 'S'
2 250 'A'
3 125 'S'

then the result should be like this

pk_stock_id Received_Qty Despatched_Qty
1 150 75
2 250 Null
3 Null 125


"
   

- Advertisement -