Add add number

  • Thread starter Thread starter JA
  • Start date Start date
J

JA

I have a group query:

SELECT Course.course_code, Course.course_name, Count
(Course.ID) AS CountOfID
FROM Course
GROUP BY Course.course_code, Course.course_name;

Is there any way I can add a numbering field (using the
build wizard or any way)to give numbering to records.

Please advise.
 
you already have a numbering field...
Course.ID

change you SQL to
SELECT Course.ID, course_code, course_name, _
Count(Course.ID) AS CountOfID
FROM Course
GROUP BY course_code, course_name;

Patrick Molloy
Microsoft Excel MVP
 
If Course.ID isn't satisfactory as a numbering field, you could try
something like this:

SELECT
C1.course_code,
C1.course_name,
( SELECT count(*) FROM Course C2 WHERE C2.Course_code <=
C1.Course_code ) as Counting
FROM Course C1 ;
 
Who said Course.ID is a number? But I admit it's a good bet. Someone
who would take a non-procedural, set-orientated language like SQL and
use it to create cursor is more than likely to choose a IDENTITY
column as a primary key, right?

--
 
Back
Top