I am not very good at SQL and I'm trying to figure out how to get the proper query result here. I am trying to use a column value and group it based on an ID and break it out into columns for two different variables. Can someone please help me on how to get to this result?
This question was closed on another thread and referenced this article (How can I return pivot table output in MySQL?). But this is summarize attributes My data is not summarizing any of this data. The order number is a unique ID of an asset and the amount is tied to that unique asset.
Current Data Set
id | ticketid | amount | Order | Number |
---|---|---|---|---|
1 | 54 | 20000 | 1 | 1234 |
2 | 54 | 23500 | 2 | 9876 |
3 | 55 | 21500 | 1 | 4567 |
4 | 55 | 22250 | 2 | 6543 |
Desired Query Result
ticketid | Order1Number | Order2Number | Order1Amount | Order2Amount |
---|---|---|---|---|
54 | 1234 | 9876 | 20000 | 23500 |
55 | 4567 | 6543 | 21500 | 22250 |