I have a Microsoft SQL Server 2008 query that returns data from three tables using a left outer join. Many times, there is no data in the second and third tables, and so I get zero, which, in my opinion, is the default value for an external outer join. Is there a way to replace the default values ββin a select statement? I have a workaround in that I can select a table variable, but it feels a little dirty.
SELECT iar.Description, iai.Quantity, iai.Quantity * rpl.RegularPrice as 'Retail', iar.Compliance FROM InventoryAdjustmentReason iar LEFT OUTER JOIN InventoryAdjustmentItem iai on (iar.Id = iai.InventoryAdjustmentReasonId) LEFT OUTER JOIN Item i on (i.Id = iai.ItemId) LEFT OUTER JOIN ReportPriceLookup rpl on (rpl.SkuNumber = i.SkuNo) WHERE iar.StoreUse = 'yes'
I would like the default number and RegularPrice to be zero if possible.
sql mysql sql-server tsql sql-server-2008
Brett Bim Nov 02 '09 at 22:56 2009-11-02 22:56
source share