我有以下 3 个类(映射到 sql 表)。
Places table:
Name(key)
Address
Capacity
Events table:
Name(key)
Date
Place
Orders table:
Id(key)
EventName
Qty
Places 和 Events 表通过 Places.Name = Events.Place 连接,而 Events 和 Orders 表:Events.Name = Orders.EventName。任务是给定一个事件,返回该事件留下的票。容量是一个地方可以容纳的数量,数量是某人订购的门票数量。因此需要在 Orders 表中进行某种分组,然后从容量中减去总和。