Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
UNPIVOT
--Sql Server 2014 Express Edition --Batches are separated by 'go' /* ID | Owner | Number_1 | Number_2 --------------------------------- 1 | John | AB-1234 | NULL --------------------------------- 2 | Tim | CD-5678 | EF-9012 --------------------------------- 3 | Eric | GH-3456 | NULL --------------------------------- 4 | Fred | IJ-7890 | KL-1234 */ select @@version as 'sql server version' CREATE TABLE #tmp ( ID int, Owner NVARCHAR(MAX), Number_1 NVARCHAR(MAX), Number_2 NVARCHAR(MAX) ) INSERT INTO #tmp (ID, Owner, Number_1, Number_2) VALUES (1,'John','AB-1234', Null), (2,'Tim','CD-5678','EF-9012'), (3,'Eric','GH-3456',NULL), (4,'Fred','IJ-7890','KL-1234') SELECT Owner, Number FROM (SELECT Owner,Number_1, Number_2 FROM #tmp) AS p UNPIVOT (Number FOR Numbers IN (Number_1, Number_2)) AS unpvt -- SELECT * FROM #tmp DROP TABLE #tmp
run
|
edit
|
history
|
help
0
Rextester.java
1
Sql Server's curse
Life cycle
1512081 QUAN LY DE TAI
SQL HW 1 Appline
Output
Ranking split across tournaments
STACK
ASSESSMENT2