0

I have a result like this Current output I understand the Group by and using Sum to get price to sum up but How can I get the part numbers to all group together in the result by comma separation?

KA-EL
  • 1

2 Answers2

1

You need to add listagg function to get the values comma seperated for that group by values.

Select  Quote_number
             ,Customer
        ,Customer_no
        ,Address
        ,Other_infor
      ,Sum(Price), LISTAGG(Part_number, ', ')
From table
Group By Quote_number
             ,Customer
        ,Customer_no
        ,Address
        ,Other_infor
Rams
  • 2,129
  • 1
  • 12
  • 19
0

In brief, you will need to Group By everything that you are not aggregating.

Select [Quote number]
      ,[Part number]
      ,[Customer]
      ,[Customer no]
      ,[Address]
      ,[Other infor]
      ,Sum([Price])
From table
Group By [Quote number]
        ,[Part number]
        ,[Customer]
        ,[Customer no]
        ,[Address]
        ,[Other infor]
Degan
  • 989
  • 2
  • 16
  • 30
  • Thanks Degan, But I am looking to have a result rolled up to a single line item per Quote number and all the parts in one col cell seperated by commas. – KA-EL Apr 04 '17 at 14:52
  • I think I may have figured it out with LISTAGG – KA-EL Apr 04 '17 at 15:07