select 100.0 * sum(survived) / count(*) as tot_pct_survived
FROM passengers
Regards
Radovan
frknozdmr01 je 26.09.2018 ob 3:03 napisal:
Hi, I need to find the percent of passengers survived? (total). How do you do
it? I tried the comment below but it did not work.
SELECT
SUM(CASE WHEN
Hi, I need to find the percent of passengers survived? (total). How do you do
it? I tried the comment below but it did not work.
SELECT
SUM(CASE WHEN survived=1 THEN 1.0 ELSE 0.0 END) /
CAST(COUNT(*) AS FLOAT)*100
AS tot_pct_survived
FROM passengers;
This is the
2 matches
Mail list logo