I have a table like this
column1 column2 column3
abc xyz 4
def ghi 3
abc xyz 6
abc xyz 1
jkl mno 4
Expected Result after query
column1 column2 column3
abc xyz 11
def ghi 3
jkl mno 4
My Query is like below:
select column1, column2, count(column3)
from
(select ......) as column1,
(select ......) as column2,
(select ......) as column3)
group by column1, column2, count(column3)
I get this error “not a single-group group function”
You need to use
SUMand you must remove thecount(column3)in thegroup byand if you really get the columns as results from sub-queries it might need to rather look like this:otherwise you would need to repeat the entirety of the sub-query select in the
group by. In your query you sayFROM (select .......) as column1but that means that the subquery is calledcolumn1which does not work. The selected columns in the subquery could be addressed by using the prefixcolumn1. For example if you sayFROM (select x from test) t1then you can address x by writingt1.x.but if you have a simple table as you describe above the correct statement is