all groups > sql server new users > december 2004 >
You're in the

sql server new users

group:

Selecting many Count(*)


Re: Selecting many Count(*) Tom Moreau
12/19/2004 3:20:33 PM
sql server new users:
Not entirely sure what you are asking, but maybe the following:

SELECT
(SELECT Count(*) FROM tblImage WHERE tblImage.Approved= 1) as
Image_Count
, (SELECT Count(*) AS Cat_Count FROM tblImageCategory) as Category_Count
, COUNT (*) as SubCategory_Count
FROM
tblImageSubCategory


--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
..
[quoted text, click to view]
Hi, Im new to this use group and this will be my first post.

I have been running in to this problem, with counting the actual rows in
three tables in the same query.
Two tables I have managed to count from, but three is over my head. I have
theese three tables:

1. Is the table with image blobs, No 2 holds image categories, and the third
holds the sub-categories. Now I want to
count the number of rows in all three tables, in one cuery to display the
counters on one page header.

So faar I have come to this:

SELECT (SELECT Count(*) FROM tblImage WHERE tblImage.Approved= 1) AS
Image_Count, Count(*) AS Cat_Count
FROM tblImageCategory

But, I have no clue how to squeese in the third table.

Cheers,
Sven

Selecting many Count(*) Sven Pernils
12/19/2004 9:08:52 PM
Hi, Im new to this use group and this will be my first post.

I have been running in to this problem, with counting the actual rows in
three tables in the same query.
Two tables I have managed to count from, but three is over my head. I have
theese three tables:

1. Is the table with image blobs, No 2 holds image categories, and the third
holds the sub-categories. Now I want to
count the number of rows in all three tables, in one cuery to display the
counters on one page header.

So faar I have come to this:

SELECT (SELECT Count(*) FROM tblImage WHERE tblImage.Approved= 1) AS
Image_Count, Count(*) AS Cat_Count
FROM tblImageCategory

But, I have no clue how to squeese in the third table.

Cheers,
Sven

Re: Selecting many Count(*) Sven Pernils
12/19/2004 11:25:42 PM
Tom,
Thanks a lot. Tried it and it works like a charm. And thanks for the fast
responce.

/Sven

"Tom Moreau" <tom@dont.spam.me.cips.ca> skrev i meddelandet
news:OTQYNhg5EHA.2180@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button