Digvijay Patil Digvijay Patil - 1 year ago 70
SQL Question

Select rows having same column value more than 3 times

I have a table called

Theater(Sn, SeatVacant)

1 Y
2 Y
3 N
. .
. .
100 Y

I want to book 3 seats(should be continuous). How can i get the continuous vacant seat.

Answer Source
select f1.sn, f2.sn, f3.sn from Theater f1
inner join Theater f2 on f1.sn=f2.sn + 1 
inner join Theater f3 on f1.sn=f3.sn + 2
where f1.SEATVACANT='Y' and f2.SEATVACANT='Y' and f3.SEATVACANT='Y' 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download