Skip to content
Advertisement

How to achieve the desired output in SQL Server 2008?

tbl_Fuel #Temp1

tbl_War #Temp2

tbl_XRay #Temp3

Desired output:

After so many Condn.. I get the data in three different temp tables… War, Fuel, XRay… I want to show the data commodity wise, if available….

I tried this query:

This query first DISTINCT data hold in another temp table, then I’m doing a few Left Joins with all temp tables, but it’s not returning the correct output.

Advertisement

Answer

You can use full join, but to avoid a Cartesian product for each commodityID, you need a sequence number:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement