Coco Beans
asked on
Return repeat Students
In oracle, I want to see people who have the same Course Description this year as they did last year
So students where Last years Course = This Years Couse
Data is stored as follows:
Student ID: 111000
Course Code: 100
Course Year: 2018
Student ID: 111000
Course Code: 100
Course Year: 2017
Any help much appreciated.
Thanks
So students where Last years Course = This Years Couse
Data is stored as follows:
Student ID: 111000
Course Code: 100
Course Year: 2018
Student ID: 111000
Course Code: 100
Course Year: 2017
Any help much appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Misread your code as a nested query. Lead would definitely be the way to go.
What is the data type of "Course Year"?
ASKER
It’s a number - 2018 etc
>>It’s a number - 2018 etc
I believe awking00 is questioning the actual data type of the column in the table. If it is a varchar2 then it is really a string holding numbers.
If it is a CHAR or VARCHAR2 then you should use TO_NUMBER around it in the queries when you perform math like subtraction. It keeps Oracle from performing an implicit data type conversion.
I believe awking00 is questioning the actual data type of the column in the table. If it is a varchar2 then it is really a string holding numbers.
If it is a CHAR or VARCHAR2 then you should use TO_NUMBER around it in the queries when you perform math like subtraction. It keeps Oracle from performing an implicit data type conversion.
ASKER
Yes it’s a number field. Thanks
Have you tried they query I posted?
Did it work? If not, please provide more sample data showing why it didn't work.
Did it work? If not, please provide more sample data showing why it didn't work.
ASKER
Thank you slightwv. Worked great
Also, why hit the table twice when you don't need to? Granted in smaller tables it likely doesn't matter but it is a bad habit to get into when you start dealing with large tables.