b-dubs
Old Hand
Points: 315
More actions
December 4, 2008 at 6:44 am
#127313
I have a table that I want to count the number of distinct rows in but I need base it off of two columns that make up the primary key.
select distinct ReqID, ClientId from employees.
How do I count the number of rows from the above query?
Garadin
One Orange Chip
Points: 29613
December 4, 2008 at 6:47 am
#907534
This may not be the most efficient way:
SELECT COUNT(*)
FROM (SELECT DISTINCT ReqID, ClientID FROM employees) E
Seth Phelabaum
Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]
December 4, 2008 at 6:51 am
#907539
Awesome. I had forgotten to alias the select clause.
Matjaz Justin
Mr or Mrs. 500
Points: 598
December 5, 2008 at 5:09 am
#908169
Maybe?
SELECT count(DISTINCT str(ReqID) + str(ClientID)) FROM employees
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply