Home Forums SQL Server 2008 T-SQL (SS2K8) Query to give sum of items with condition from multiple tables RE: Query to give sum of items with condition from multiple tables

  • rosarozina - Tuesday, November 14, 2017 9:26 AM

    What I want is to show all the CostCodeIDs show on the table even  If the cost is not present for particular jobid then count should be 0 corresponding to that jobid.

    Is this not as simple as changing the first INNER JOIN to a LEFT JOIN?

    A word of advice - alias your tables, and use the aliases to qualify every column name, whether in the SELECT list, the WHERE clause or a join predicate.  It'll make your query easier to ready and guard against ambiguous column names in the future.

    John