Listing data from multiple Queries

mdlong

New member
Local time
Today, 12:46
Joined
Apr 27, 2012
Messages
1
Hi there, I was wondering if someone could help.

I am currently using the Northwind Database.
I have 4 queries that are identical showing (Category, Revenue) but differing by obtaining revenue by Quarter: 1995 - Q1, Q2, Q3, Q4.

Is there a way to combine this data (or build in one SQL statement) so that it displays (Category, RevQ1, RevQ2, RevQ3, RevQ4)?

Example: 'Q3Revenue1995' (sorry about my inefficient code!) :

SELECT c.categoryName as Category, Sum(od.UnitPrice*od.Quantity) AS Revenue
FROM categories AS c, [Order details] AS od, products AS p, Orders AS o
WHERE c.categoryID = p.categoryID AND p.productID = od.productID AND od.OrderID = o.OrderID AND (o.shippeddate between #7/1/1995# And #9/30/1995#)
GROUP BY c.categoryName
ORDER BY 2 DESC;


I'm sure there is an easy way but I am fairly new to this!

Thank you for your time,

Matt
 
Last edited:
You can use a crosstab query (use the wizard to build it for you). Select the entire year. The wizard will recoginze that you are pivoting a date and give you the option of doing quarters.
 

Users who are viewing this thread

Back
Top Bottom