system
October 22, 2012, 1:42pm
1
HI folks,
I am working in MSSQL and trying to pull out
COURSE_PRODUCT_ID and COURSE_NAME but only the in the first instance of each COURSE_PRODUCT_ID.
This doesn’t work:
SELECT DISTINCT
Course.COURSE_PRODUCT_ID,
Course.COURSE_NAME
FROM Course
ORDER BY Course.COURSE_NAME
It returns every record. Can anyone tell me how to get it to only return the first instance
of each COURSE_PRODUCT_ID?
Thanks in advance
Dave
r937
October 22, 2012, 2:17pm
2
something is seriously amiss
if you run a DISTINCT on both course_product_id and course_name, and it “doesn’t work” to produce only one instance of course_product_id, then this implies that there are course_product_id values that have multiple different course_name values
your data is b0rked
davecheet:
HI folks,
I am working in MSSQL and trying to pull out
COURSE_PRODUCT_ID and COURSE_NAME but only the in the first instance of each COURSE_PRODUCT_ID.
This doesn’t work:
SELECT DISTINCT
Course.COURSE_PRODUCT_ID,
Course.COURSE_NAME
FROM Course
ORDER BY Course.COURSE_NAME
It returns every record. Can anyone tell me how to get it to only return the first instance
of each COURSE_PRODUCT_ID?
Thanks in advance
Dave
What do you define as the first instance? Last course entered? First of the day?