You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if support boolean return 0 or 1 , can optimize sql :
The percentage of delays by carrier for 2007
SELECT Carrier, c, c2, c*100/c2 as c3
FROM
(
SELECT
IATA_CODE_Reporting_Airline AS Carrier,
count(*) AS c
FROM ontime
WHERE DepDelay>10AND Year=2007GROUP BY Carrier
) q
JOIN
(
SELECT
IATA_CODE_Reporting_Airline AS Carrier,
count(*) AS c2
FROM ontime
WHERE Year=2007GROUP BY Carrier
) qq USING Carrier
ORDER BY c3 DESC;
Better version of the same query:
SELECT IATA_CODE_Reporting_Airline AS Carrier, avg(DepDelay>10)*100AS c3
FROM ontime
WHERE Year=2007GROUP BY Carrier
ORDER BY c3 DESC
Summary: make some functions work with boolean datatypes.
So we can transform
avg(boolean)
--->avg(uint8)
Now databend boolean return true/false , like this:
if we can make boolean return 0/ 1 like this:
if support boolean return 0 or 1 , can optimize sql :
The percentage of delays by carrier for 2007
Better version of the same query:
Originally posted by @wubx in #3267
The text was updated successfully, but these errors were encountered: