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.
| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2009-09-01 : 03:03:00
|
| Dear All,I am haveing following two tables,queary and their outputs.In that both table as T_CD_IMPORT and T_BANK_IMPORT_BI haveing same database field as FLEXI_2.Now i want to match total from both table who's ID same and put the 'M' in FLEXI_2 columns.Those record are matching put 'M' otherwise put 'P' in FLEXI_2 column.So can anybody tell me how to write procedure for that ?SELECT sum(cast(Amount as decimal(18,2))) as CHANN_AMOUNT,PK_CH_SCHEME_ID FROM T_CD_IMPORT WHERE TRADE_DATE = '4/13/2009' AND cast(AMOUNT as decimal(18,2)) <>0 and flexi_2 IS NULLgroup by PK_CH_SCHEME_IDOutput:3500.00 1500.00 24000.00 51000.00 9SELECT sum(cast(CREDITS as decimal(18,2))) as BANK_CREDIT,PK_SCHEME_ID FROM T_BANK_IMPORT_BI WHERE DATE = '4/13/2009' AND cast(CREDITS as decimal(18,2)) <>0 and flexi_2 IS NULL group by PK_SCHEME_IDOutput:3500.00 1500.00 21000.00 96000.00 20ThnksHarish Patil |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-02 : 06:10:45
|
| join on the common fields and use CASE WHEN in update to check for totals and populate values M /P |
 |
|
|
|
|
|