Count no of occurences of elements in single row
I got a requirement like i need to find number of occurences of particular
value in a single row of an oracle table.
Say my source table looks likes this,
ID score1 score2 score3 score4 score5
---------------------------------------------
aa -1 65 -1 -1 82
bb -1 65 99 14 82
I need a query which will return the results like,
ID score1 score2 score3 score4 score5 count ( count of -1
occurences)
------------------------------------------------------
aa -1 65 -1 -1 82 3
bb -1 65 99 14 82 1
And the version of oracle i'm using is Oracle 10g (so using PIVOT options
ruled out).can anyone help me out solving this issue.
No comments:
Post a Comment