SQL Query Help

Status
Not open for further replies.

enjoy

Journeyman
I have a table "formdetails". Fields (Id, formid, ..., cb)
Id+formid = primary key
cb contains either 0,1 (text)

Each Student (Id) can fill a form multiple times, so each student will have "formid" starting from 1, 2..and so on. (Number of forms per student varies).

I need a list of "Id" which has the highest "formid" and where cb="1"

I mean, I have to consider the tuple for each student which has the highest "formid" for that particular student.

Thanks for your help.
 

mod-the-pc

Back to School Mr. Bean !
Select
A.id,
A.formid
From
Formdetails A
Where
A.cb='1'
And A.formid=(select Max(b.formid) From Formdetails B Where B.id=a.id)
 
Status
Not open for further replies.
Top Bottom