Hello all,
I have one table which contain SelBuy flag. My table looks like,
IF OBJECT_ID(N'tempdb..#tmpList', N'U') IS NOT NULL
Begin
DROP TABLE #tmpList;
End
Create Table #tmpList
(
SelSRNO Bigint,
SelRate Float,
SelQty Float,
BuySrno Bigint,
BuyRate Float,
BuyQty Float,
SelBuy varchar(20),
CustName varchar(50)
)
INSERT Into #tmpList(SelSRNO,SelRate,SelQty,BuySrno,BuyRate,BuyQty,SelBuy,CustName)
Select 1 SelSRNO,10 SelRate,10 SelQty,0 BuySrno,0 BuyRate,0 BuyQty,'S' SelBuy,'Manoj' CustName
Union
Select 2 SelSRNO,12 SelRate,12 SelQty,0 BuySrno,0 BuyRate,0 BuyQty,'S' SelBuy,'Manoj' CustName
Union
Select 0 SelSRNO,0 SelRate,0 SelQty,7 BuySrno,40 BuyRate,30 BuyQty,'B' SelBuy,'Manoj' CustName
Union
Select 3 SelSRNO,22 SelRate,24 SelQty,0 BuySrno,0 BuyRate,0 BuyQty,'S' SelBuy,'MANOJ-1' CustName
Union
Select 0 SelSRNO,0 SelRate,0 SelQty,7 BuySrno,110 BuyRate,120 BuyQty,'B' SelBuy,'MANOJ-1' CustName
Union
Select 0 SelSRNO,0 SelRate,0 SelQty,9 BuySrno,40 BuyRate,40 BuyQty,'B' SelBuy,'MANOJ-1' CustName
Select * from #tmpList
Order By CustName,SelBuy Desc
I want to select record Sel and Buy based on SelBuy Flag.
Selectd record like,
SelSRNO SelRate SelQty BuySrno BuyRate BuyQty CustName
1 10 10 7 40 30 Manoj
2 12 12 0 0 0 Manoj
3 22 24 7 110 120 MANOJ-1
0 0 0 9 40 40 MANOJ-1
Please help me for select record in this format.