troubleshooting Question

Sql server 2000 query

Avatar of johnnyg123
johnnyg123Flag for United States of America asked on
Microsoft SQL Server 2005
2 Comments1 Solution248 ViewsLast Modified:
I have 4 ms sql server 2000 tables with the same layout but populated with 4 different quarters of data for shops
(I know it is in the sql server 2005 zone but there was no 2000 zone)

Since shops open and close somewhat frequently,  it is possible that a shop may not exist in all the tables

Here is a sample of data

Quarter1 Table

Shopid   SalesQ1
1000       100000


Quarter2 Table

Shopid   SalesQ2
1000       200000
3000       300000


Quarter3 Table

Shopid   SalesQ3
1000       300000



Quarter4 Table

Shopid   SalesQ4
1000       400000
2000       200000



I am trying to write a query that will retrieve shop and list the data
for each quarter.  (if sales don't exist for a quarter I would like 0)

Given the sample data I would like

ShopID   SalesQ1   SalesQ2  SalesQ3   SalesQ4
1000       100000    200000    300000    400000
2000        0             0              0              200000
3000        0             300000    0              0
 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros