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 - 2011-11-21 : 01:40:55
|
| Dear All,I am using folowing query for taking count from two table and getting following output. But when data is not availbale in "tb_lcr_normalized_rate_sheet_BK" table then it should show 0 just like Desired Output. But through this query if record is not available in backup table then it's not return any output.Can anybody please solve my issue ?Query:select rs.ID,COUNT(nr.ID) As NormalizedCountOriginal,COUNT(nrs.ID) As NormalizedCountBackup from tb_lcr_rate_sheet rs inner join tb_lcr_work_sheet ws on rs.ID = ws.Rate_Sheet_IDinner join tb_lcr_normalized_rate_sheet nr on ws.ID = nr.Work_Sheet_IDinner join tb_lcr_normalized_rate_sheet_BK nrs on nr.ID = nrs.IDwhere rs.status = 0 group by rs.ID Output: ID tb_lcr_normalized_rate_sheet tb_lcr_normalized_rate_sheet_BK 123 70 70Desired Output: ID tb_lcr_normalized_rate_sheet tb_lcr_normalized_rate_sheet_BK 123 70 0Thanks and Regard'sHarish Patil |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-21 : 02:33:59
|
| Change last inner join into Left joinMadhivananFailing to plan is Planning to fail |
 |
|
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-11-21 : 03:19:47
|
| Hello Madhivanan,Thnks. I resolved my issue.Thanks and Regard'sHarish Patil |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-11-21 : 04:17:32
|
quote: Originally posted by hspatil31 Hello Madhivanan,Thnks. I resolved my issue.Thanks and Regard'sHarish Patil
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|