Answer the question
In order to leave comments, you need to log in
How to get a selection from the same table for different conditions?
For example, there is a table in postgres:
|user_id | message |
|---------|----------------|
|1 | Bought Lada |
|1 | Bought Volvo |
|1 | Bought Kia |
|2 | Bought Lada |
|3 | Bought Kia |
|3 | Bought Kia |
There can be only 3 car brands: Lada, Volvo, Kia. Tell me how to make a request so that the answer is:
|user_id| Lada | Volvo | Kia |
| 1 | 1 | 1 | 1 |
| 2 | 1 | 0 | 0 |
| 3 | 0 | 0 | 2 |
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question