我正在尝试添加此查询中的结果数。 UCASE(RIGHT(DepartureTime,2))
给我四个PM,一个AM给五个。我希望它只是一个AM柱和一个PM柱,EX:AM | 1,ABOVE PM | 4。
我目前收到错误
您的查询不包含指定的表达式“
UCASE(RIGHT(DepartureTime,2))
”作为聚合函数的一部分
SELECT UCASE(RIGHT(DepartureTime,2)) AS [Time of Departure], COUNT(*) AS [PassengerCount]
FROM Flight
WHERE FlightNumber IN
(SELECT FlightNumber
FROM Manifest
WHERE FlightDate BETWEEN #07/01/2016# AND #12/31/2016# AND PassengerNumber IN
(SELECT PassengerNumber
FROM Passenger
WHERE FFNumber IN
(SELECT FFNumber
FROM FrequentFlyer
WHERE PremierStatus = 3)));
答案 0 :(得分:0)
您收到错误是因为您在查询中引入了一个聚合函数,而没有在最后附加guard let currentViewController = self.VCArr.first else { return }
子句。
通过添加GROUP BY
修改您的查询。 GROUP BY DepartureTime
子句将您的记录分组为摘要。
下面的代码应该会给你预期的结果,但我还没试过。
GROUP BY