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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query 2

Status
Not open for further replies.

dakotauk

Technical User
Oct 16, 2002
30
GB
I have created 3 SQL query which counts the records within table but the title of it is EXPR1000 is there any way of changing this, within the SQL query.

SELECT count(*)
FROM Not_Checked_QRY;

I want to use 3 queries to create a chart that automatically records if the values alter in each of the three queries, but need to change EXPR1000 so I can seperate the values?

Any Ideas?

Cheers
 
ignore first part :D solved it.

How can I put three counts on one query.

Table 1 : 37 items
Table 2 : 32 items
Table 3 : 11 items

All i can do is return one set before I get SQL errors for adding more to the query.

Im just learning basics and would very much like your help.

Thanks in advance.
 
I would use a UNION query in a case like this...

Code:
SELECT 'Table1', COUNT(*) 'Items'
FROM Not_Checked_QRY;
UNION
SELECT 'Table2', COUNT(*) 'Items'
FROM Table2Name;
UNION
SELECT 'Table3', COUNT(*) 'Items'
FROM Table3Name;

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
great thanks, now is there a way of having the data arrange as seperate columns ie

Table 1 Table 2 Table 3
37 32 11

so each table would have its own heading?
 
SELECT Count(*) AS Table1
,(SELECT Count(*) FROM [Table 2]) AS Table2
,(SELECT Count(*) FROM [Table 3]) AS Table3
FROM [Table 1]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you both for your very helpful suggestions.

All The Best

Gaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top