Skip to main content

Timeline for Merging data from multiple tables

Current License: CC BY-SA 3.0

3 events
when toggle format what by license comment
Oct 27, 2015 at 13:31 comment added Jonathan Fite @Sean, I'm willing to bet that you have NULLS for some of the values that you are hanging additional tables off of. For example, the o.ShippedDate is likely going to be NULL for any orders that haven't shipped yet. In that case, change the join type to a LEFT OUTER. When I'm trying to figure this kind of stuff out and I don't have a good/accurate data model to work off of, I typically reduce the query to it's basics. In this case, just the order and order details table to verify my numbers. Then add each additional table one at a time until I identify the issue.
Oct 27, 2015 at 7:14 comment added Sean Thank you. Yes I'm using MS SQL Server. I'm quite new to SQL and learning on my own so don't have too much knowledge about joins. If I specify the join for db1.dbo.Products as (INNER JOIN db1.dbo.Products p ON p.ProductID=od.ProductID), the number of rows returned is way too less. The expected output should be the sum of number of rows in orders and order details tables. Not sure what am I missing?
Oct 26, 2015 at 13:02 history answered Jonathan Fite CC BY-SA 3.0