473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

can someone help me with this SQL query?

I have a table of raw sales data which I want to query, so the output can
be imported into Excel and charted. The raw data looks like this, with
one record for each sale:

table 'data'

date size
1/6/04 medium
1/5/04 small
1/6/04 medium
2/6/04 large
3/6/04 medium
3/6/04 large
etc.

What I want to chart is the number of sales for each size on a daily
basis, i.e.

date small medium large
1/6/04 1 2 0
2/6/04 0 0 1
3/6/04 0 1 1

I succeeded in writing a query which can give me the data for one size,
i.e.

SELECT data.DATE, Count (SIZE) AS size total
FROM data
WHERE size = 'small'
GROUP BY data.DATETIME;

which gives me

date small
1/6/04 1
2/6/04 0
3/6/04 0

But I am unable to extend the query to give me all 3 size summaries in
one table.

Any help appreciated.

~richard

Nov 13 '05 #1
1 1233
JHB
Hi Richard
TRANSFORM Count(data.Size) AS AntalOfSize
SELECT data.Date
FROM data
GROUP BY data.Date
PIVOT data.Size;

Regards
Jørn
"richard" <no****@myplace.net> skrev i en meddelelse
news:z6*****************@news-server.bigpond.net.au...
I have a table of raw sales data which I want to query, so the output can
be imported into Excel and charted. The raw data looks like this, with
one record for each sale:

table 'data'

date size
1/6/04 medium
1/5/04 small
1/6/04 medium
2/6/04 large
3/6/04 medium
3/6/04 large
etc.

What I want to chart is the number of sales for each size on a daily
basis, i.e.

date small medium large
1/6/04 1 2 0
2/6/04 0 0 1
3/6/04 0 1 1

I succeeded in writing a query which can give me the data for one size,
i.e.

SELECT data.DATE, Count (SIZE) AS size total
FROM data
WHERE size = 'small'
GROUP BY data.DATETIME;

which gives me

date small
1/6/04 1
2/6/04 0
3/6/04 0

But I am unable to extend the query to give me all 3 size summaries in
one table.

Any help appreciated.

~richard

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sbandy | last post by:
--=====================_11749194==_.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed I am new in mysql.... I wrote this query: INSERT INTO testo (id_lingua, id_categoria,...
0
by: Mike Chirico | last post by:
Hopefully this will help someone... Helpful Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Last Updated: Fri Apr 16 11:47:34 EDT 2004 The latest version of this...
3
by: Randell D. | last post by:
Folks, I'm working on an ecommerce website that deals with credit card expiry dates. The table has two columns for year and month. I currently have a select that says: ...
7
by: Dan V. | last post by:
Situation: I have to connect with my Windows 2000 server using VS.NET 2003 and C# and connect to a remote Linux server at another company's office and query their XML file. Their file may be...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
1
by: Melissa Kay Beeline | last post by:
OK, here's the sitch : we have an access control system at work that registers ever entry/exit of every employee. I recently made some queries in Access so the ppl in HR could make reports (who...
3
by: chucher | last post by:
I´m developing a database in access about invoices that could use to different kinds of money (US Dollar and Pesos). I have a form where you can insert the invoices and de items of de invoice. I...
2
by: blueyonder | last post by:
The statament below does exactly what I want it to do but I don't understand why? In my mind the subquery produces a result set which is a subset of the handset table which the initial part of...
8
by: daicamad | last post by:
I have this: SELECT UserInfo.EmpID, UserInfo.FirstName, UserInfo.LastName, Sum(SoldItems.Commision) AS TotalCommission, Sum(TIP.TipAmt) AS TotalTip,(SELECT Sum(SoldItems.Commision) AS MyCommission...
0
by: sara | last post by:
Hi - I posted this earlier and didn't get any response. Hopefully someone can help?? I have a table keeping track of employees' jobs in a location. So, Store #1 Manager #353, AsstMgr #556...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.