salve ragazzi ho un problema nel calcolare la la percentuale in postgres 8.x
nel primo esempio funziona correttamente
ora io vorrei fare una cosa del genere per evitare di scrivere codice ripetutoCodice PHP:SELECT
ROUND(100.0 * (cast(count(case scolarita when '4' then 1 end) as decimal) / cast(COUNT(case id_questionario when 2 then 0 end) as decimal)), 3) AS percent_laurea
FROM mytable
solo che totale1 dice che è una colonna che non esiste...Codice PHP:SELECT
(count(case scolarita when '1' then 1 end) as totale1
ROUND(100.0 * (cast(totale1) as decimal) / cast(COUNT(case id_questionario when 2 then 0 end) as decimal)), 3) AS percent
FROM mytable
avete suggeriemnti a riguardo?
grazie

Rispondi quotando