I would like to ask you how to create a class column from tow numeric columns in SQL Server like below.
Thank you for your help
DECLARE @Table TABLE (ID INT, Name NVARCHAR(20), Value1 INT, Value2 INT);
INSERT INTO @Table (ID, Name, Value1, Value2) VALUES
(1, 'A', 5, 2), (2, 'B', 6, 3), (3, 'C', 9, 4), (4, 'D', 8, 7),
(5, 'E', 2, 10);
1条答案
按热度按时间irlmq6kh1#
The way you do this is going to depend on how exactly you want your result to work. If you just want get the results of value1 and value2 on a per row basis you could:
If you want to consider the full path (who's this ones parent?), you'll need some sort of recursive behavior, like: