Below is the scenario
i have codes column in this there are multiple values
now i need to group 3 or 4 values into one group. like below
001, 002 ,003 into one group
004,005,006 into one group like wise.
we are fetching the columns
sel col1,col2,sum(col3),sum(col4) from tbl
group by 1,2
Expecting scenario: (adding 'codes' field)
sel col1,codes,col2,sum(col3),sum(col4) from tbl
group by 1,2,3
Note: here codes field has multiple rows as above mentioned and those values we have to combine into multiple groups.
Please suggest me how we can do this.
I don't fully understand what you're trying to do.
Seems like a GROUP_CONCAT aggregate, see
Thanks Dieter for your reply,
Scenario is like this, i have 10 values in a field which are coming from source and i need to assign a value(ex: 1 or 2 or 3 etc..) for each 3 values like grouping.
Ex: from source below are the values i am getting
now i need to assign a value like below
for values 1,2,3 i need to assign 1
for values 4,5,6 i need to assign 2
for values 7,8,9,10 i need to assign 3
i have achieved this by using CASE statement for above scenario is there any other method which we can use to achieving this.
(case when col1 in('0','1','2','3','4','5') then 1
when col1 in('6','7','8','9','10','14') then 2
when col1 in('17','22','23','25','51','52') then 3
end) as col1