我有3个表客户(customerid,名称),customerbooking(bookingid,customerid),transact(transacted,bookingid,typeoftransaction)
我想获取具有最大typeoftransact ='current'的'customer name'的名称。客户表通过customerid链接到customerbooking,而customerbooking通过bookingid链接到transact。使用join我可以获取单个记录,但无法获得Max值
答案 0 :(得分:0)
请尝试以符合您的方案
SELECT
C.Name
, Count(BookingID)
FROM Customer C
INNER JOIN customerbooking CB ON CB.CustomerID = C.customerId
INNER JOIN transact T ON T.bookingid = CB.BookingId
WHERE T.Typeoftransaction='current'
GROUP BY C.Name
希望这有帮助