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 2008 Forums
 Transact-SQL (2008)
 select query with left join and inner join

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-05-12 : 14:26:47
I am using teh following query with left join, i get rows progid other than 30 also.

SELECT t.ProgID, t.taskid,isnull(t.PctComplete,0),isnull(t.award_amt,0), ISNULL(SUM(c.amount),0)
FROM tab_tasks t
left JOIN tab_costdet c ON (t.TaskID = c.TaskID and t.ProgID=30)
GROUP BY t.ProgID, t.taskid, t.award_amt, t.Pctcomplete

When i use inner join i get zero for that reason using left join but the problem is, it is getting all progid rows available. just want to get progid = 30 rows.

Thank you very much for the helpful info.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-12 : 14:30:15
move the t.progid = 30 to a WHERE clause

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -