I am a beginner with SQL and have a question. I have a table with user data like this
uid nid val
+---+---+---+
| 1 | x | 3 |
+---+---+---+
| 2 | x | 3 |
+---+---+---+
| 3 | x | 3 |
+---+---+---+
| 1 | y | 4 |
+---+---+---+
| 2 | y | 4 |
+---+---+---+
| 3 | y | 4 |
+---+---+---+
| 1 | z | 5 |
+---+---+---+
Where uid is a user ID, nid is a Name id which is used to identify a value and val is the actual value.
I want to write a query which gives the following result
uid x y z
+---+---+---+---+
| 1 | 3 | 4 | 5 |
+---+---+---+---+
| 2 | 3 | 4 | 0 |
+---+---+---+---+
| 3 | 3 | 4 | 0 |
+---+---+---+---+
Are there functions or statements that can read data from multiple rows and put it in columns ?
PIVOTor conditional aggregation