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!

RUNNINGCOUNT-SO-FAR function ??

Status
Not open for further replies.

milton747

Programmer
Apr 21, 2005
133
US
Hi,
I wish there was a RUNNINGCOUNT-SO-FAR function.
I have got the 1st 3 cols including ROWSPERCOUNTRY. (See SQL below) I've played with various aggregates, but can't get the WANT_UNIQUE_WITHIN_COUNTRY column.
Essentially a unique number for each customer within its country. (Restarts for each country)

Suggestions very welcomed
Milton


COUNTRY | CUNAME | ROWSPERCNTY | WANT_UNIQUE_WITHIN_COUNTRY
Aus | CustA | 3 | 1
Aus | CustB | 3 | 2
Aus | CustC | 3 | 3
Bel | CustE | 1 | 1
Can | CustD | 2 | 1
Can | CustX | 2 | 2



SELECT DISTINCT
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME,
sqa.RTX

FROM CUSTOMERS

INNER JOIN
(SELECT
CUSTOMERS.COUNTRY,
COUNT (DISTINCT CUSTOMERS.CUSTOMERNAME ) AS RTX
FROM CUSTOMERS
GROUP BY CUSTOMERS.COUNTRY
) sqa
ON sqa.COUNTRY = CUSTOMERS.COUNTRY

order by
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top