jklipa
0 pts. | Jan 8 2007 8:50AM GMT
If all you want is a count showing total students by unique ID then why not use this simple select statement…:
select ID, count(*) from mylib/myfile
group by ID
order by ID
And if you’re interested in counting duplicate records you can use:
select ID, count(*) from mylib/myfile
group by ID
having Count(*) > 1
order by ID
hth
epistemology
0 pts. | Jan 8 2007 11:42AM GMT
To count the records for each student in 9i you use the following analytical function (do not use a GROUP BY):
SELECT ROW_NUMBER() OVER (PARTITION BY ID) AS CNT,
ID, NAME, PLAN, DESCR
FROM MY_TABLE;
To get the exact result shown where only the first row has a “1″ and the other rows are NULL
SELECT DECODE(CNT,1,1,NULL) CNT, ID, NAME, PLAN, DESCR
FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY ID) AS CNT,
ID, NAME, PLAN, DESCR
FROM MY_TABLE);
Try it!






