Count(*)

UDA

Count(*)

Hi people, I am writing an SQL who retrieves info from 3 tables, lets call them A, B and C, but the only field that I need to see is count(*) from A table. How do I write this? I tried count(A.*) and count(*.A) but it did not work.

Thanks
3 REPLIES
Enthusiast

Re: Count(*)

If you have a column that's defined as NOT NULL on A, then you could do a:

select count(a.colname)

You would have to pick a non-null column though.
Enthusiast

Re: Count(*)

In other words, count(a.colname) excludes all the null value and returns the count, on a column which can hold null value.
Enthusiast

Re: Count(*)

why don't you use a derived table in your query ?

ie something like ...

SELECT * FROM
B,C,
(
SELECT COUNT(*) FROM A
)ACNT(CNT)
WHERE
B.col1 = C.col1