Reputation: 15
I need help in a query to get me result as below based on this table.
Table
ID Date Value
--- ---- -----
1 jan1 Hello
2 Jan2 Sample
Query Result:
ID Date Value Info
--- ---- ----- -----
1 jan1 Hello A
1 jan1 Hello B
2 Jan2 Sample A
2 Jan2 Sample B
Can any help me please?
Upvotes: 0
Views: 31
Reputation: 118
If you are wanting the info column to be based on the values of another column, use case.
Upvotes: 0
Reputation: 521053
You can use a UNION
here, with a computed column for Info
:
SELECT ID, Date, Value, 'A' AS Info
FROM yourTable
UNION ALL
SELECT ID, Date, Value, 'B'
FROM yourTable
Upvotes: 1