This Query is Simple, but I still don't know to handle it.
I must Select Average From Many Column But Only Column with Integer Value.
like this
SELECT AVG(SET_O_1A) AS SET_O_1A,
AVG(REAL_O_1A) AS REAL_O_1A,
AVG(SET_O_1B) AS SET_O_1B,
AVG(REAL_O_1B) AS REAL_O_1B,
AVG(SET_PRE_1A) AS SET_PRE_1A,
AVG(REAL_PRE_1A) AS REAL_PRE_1A,
AVG(SET_PRE_1B) AS SET_PRE_1B,
AVG(REAL_PRE_1B) AS REAL_PRE_1B,
AVG(SET_O_2A) AS SET_O_2A,
AVG(REAL_O_2A) AS REAL_O_2A,
AVG(SET_O_2B) AS SET_O_2B,
AVG(REAL_O_2B) AS REAL_O_2B
FROM table
WHERE ALL column > 0;
How to Fix Problem like this?
I have try like this but still not working
SELECT * FROM (SELECT AVG(SET_O_1A) AS SET_O_1A,
AVG(REAL_O_1A) AS REAL_O_1A,
AVG(SET_O_1B) AS SET_O_1B,
AVG(REAL_O_1B) AS REAL_O_1B,
AVG(SET_PRE_1A) AS SET_PRE_1A,
AVG(REAL_PRE_1A) AS REAL_PRE_1A,
AVG(SET_PRE_1B) AS SET_PRE_1B,
AVG(REAL_PRE_1B) AS REAL_PRE_1B,
AVG(SET_O_2A) AS SET_O_2A,
AVG(REAL_O_2A) AS REAL_O_2A,
AVG(SET_O_2B) AS SET_O_2B,
AVG(REAL_O_2B) AS REAL_O_2B
FROM table) as ORI
WHERE ORI > 0;
Can Anyone help this? Thanks in Advance
Tabel like this
ID | ph | ph2
========================
1 | 10 | 20
2 | NA | 20
3 | 11 | 10
and I Hope the result like this
ID | ph | ph2
========================
1 | 10.5 | 16.67
so The query only average column with number only.
WHERE ALL column > 0
?column > 0
does not test for "Column with Integer Value". Please clarify.