Sunday, August 8, 2010

Fetch out More than 3 entries for one name and class column

Suppose you want to Fetch out More than 3 entries in a class with the same name of student, than you can use following query:
Here Id is table's primary key.

Select * from Table1 t6
where Id < (select MAX(Id) from (Select * from Table1 t4
where Id < (select max(Id) from (Select * from Table1 t2
where Id < (select Max(Id)from Table1 t1 where = and t1.class = t2.class)) t3 where t4.class= t3.class and = )) t5 where t6.class= t5.class and = )
order by desc


No comments:

Post a Comment