Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Multiple Select Statements

Status
Not open for further replies.

pickletech

IS-IT--Management
Dec 20, 2004
88
US
Hello everyone, I am trying to create a small report that displays how many users are running Windows 2000 and XP, and how many users are using Office 2000 and 2003 for a Microsoft True Up. I have these four SELECT statements in four separate queries:
SELECT count(Workstations.OS) AS Win2000cnt
FROM Workstations
WHERE (Workstations.OS="Win 2000")
SELECT Count(Workstations.OS) AS WinXPcnt
FROM Workstations
WHERE (((Workstations.OS)="Win XP"))
SELECT count(Workstations.[Office Ver]) AS Office2000cnt
FROM Workstations
WHERE (Workstations.[Office Ver]="2000")
SELECT count(Workstations.[Office Ver]) AS Office2003cnt
FROM Workstations
WHERE (Workstations.[Office Ver]="2003")

Is there any way to combine them? I can't figure out how to create my report to display from separate queries, or how to combine these into one query. Sorry, I am a bit of a noobie.
Thank You,
PickleTech
 
Code:
SELECT Workstations.OS, count(*) AS [NumberOfWorkStations]
FROM Workstations
GROUP BY Workstations.OS
 
That works excellent for getting the OS (the first 2 SELECT statements) but is there any way to incorporate the Office Versions too (the last two queries)?
 
SELECT "Windows", OS, Count(*) AS [NumberOfWorkStations]
FROM Workstations
GROUP BY OS
UNION
SELECT "Office", [Office Ver], Count(*)
FROM Workstations
GROUP BY [Office Ver]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Awesome! Thank you very much. Stars all around!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top