0

I have a table with the following columns: date, type, area, district I want the select output to look like this: date, type1_area, type2_area, district I understand the first step is a groupby over date and district but I don’t know how to combine the values into a single row.

Any help will be greatly appreciated.

1
  • Please include some sample input data, along with the output you would expect. Commented May 30, 2019 at 9:23

1 Answer 1

2

Your textual description seems to imply that you want a query along these lines:

select
    date,
    string_agg(type || '_' || area, ', ' order by type) type_area,
    district
from your_table
group by
    date,
    area,
    district;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.