Autoincrement based on a set of other columns
- by slack3r
I have a table Course and every Course has many Resources.
Course
==========
course_id
Resource
==========
course_id
number
I want something like a seperate autoincrement for each course_id. Or, in other words, I want to auto-enumerate the resources for a given course. For example, the resource table could look something like:
course_id | number
==================
1 | 1
1 | 2
2 | 1
1 | 3
1 | 4
2 | 2
2 | 3
and so on.
I want to do this in SQL, using IBM DB2.