1.11M Members

how can i grab the last value of the coloumn

 
0
 

I have three tables
1.course(c_id(pk),c_name,sem_no);
2.student(s_id(pk),s_name,user_name,password);
3.student_info(s_id(fk),c_id(fk));

i have logged in the student..
den i run this query

select distinct sem_no from course,student_info where course.c_id=student_info.c_id and s_id='0001' order by sem_no;

it shows all the semster he passed inclueding the running semster..

now i want to show the last value of sem_no coloumn as his current semster..
how can i grab the last value of the sem_no???

 
0
 
SELECT MAX(COURSE.SEM_NO) FROM COURSE, STUDENT_INFO
WHERE COURSE.C_ID=STUDENT_INFO.C_ID
AND STUDENT_INFO.S_ID='0001';
 
0
 

You can try the below SQL Query

select top 1 sem_no from course, student_info
where course.c_id=student_info.c_id
and student_info.s_id='0001';
order by sem_no desc

have a good day :)

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: