gpt4 book ai didi

sql - 选择具有相同列值的行超过 3 次

转载 作者:行者123 更新时间:2023-12-04 22:02:48 26 4
gpt4 key购买 nike

我有一张名为Theater(Sn, SeatVacant)的 table

e.g SN SEATVACANT
1 Y
2 Y
3 N
. .
. .
100 Y

我要订3个座位(应该是连续的)。我怎样才能得到连续的空位。

最佳答案

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'

关于sql - 选择具有相同列值的行超过 3 次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38379708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com