Reputation: 9
I select data with group by
select rkey from asset group by rkey
this will give me:
ADATUM
BEZ1
KLASSE
AWERT
ANLNR
LOCATION
BEZ2
BKRS
UNR
now, how can I count the result, so that I get (9). If it works, in one SELECT Statement.
Upvotes: 0
Views: 2180
Reputation: 79929
SELECT COUNT(rkey)
FROM
(
select rkey from asset group by rkey
) t
Or, you can get rid of the GROUP BY
and use DISTINCT
instead, because the inner query with select rkey from asset group by rkey
is acting like DISTINCT
. So you can do it in one query:
SELECT COUNT(DISTINCT rkey)
FROM asset
Upvotes: 4
Reputation: 25753
You can try to use distinct
select count(distinct rkey)
from asset
Upvotes: 1