View not displaying all results

  • I have created a view thats pulling data from two different tables to combine them into one report.

    table 1 lists the client code and table 2 lists the client partner and they're linked by a variable.

    When running the report the result shows the client codes with their respective partner however any client codes that didn't have a partner are not displaying in the report and I need all client codes to be displayed even if there's no partner.

    Is there a way I can make this display all results and if the client partner doesn't exist for it to still display as 'Null' for the partner but still display the client code?

    Script:

    SELECT TOP (100) PERCENT C.cltCode AS ClientCode, C.cltSortName AS SortName, C.cltTerminationDate AS [Term date], dbo.vcltAttrib6.ainTVal AS Department,

    C.objInstID AS ClientID

    FROM dbo.cdbClient AS C INNER JOIN

    dbo.vcltAttrib6 ON C.objInstID = dbo.vcltAttrib6.ainObjectInstID

    GROUP BY C.cltSortName, C.cltTerminationDate, dbo.vcltAttrib6.ainTVal, C.objInstID, C.cltCode

    ORDER BY ClientID

  • Just quickly off the top of my head, and without looking in detail at the query, have you looked at left and right joins instead of the inner join?

    Give me everything from table 1 regardless of its existence in table 2 and then give me details, where they exist, from table 2? This would be a left outer join.

  • Agree with previous comment. Try changing INNER JOIN to LEFT JOIN and see whether that helps you.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply