数据保存在表格中如下。
我需要显示如下数据。
请建议查询
答案 0 :(得分:0)
这是在SQL Server中执行此操作的方法:
SELECT Name, 'Joined' AS [ACTION], JOIN_DT AS ACTION_DATE
FROM SomeTable
UNION ALL
SELECT Name, 'Started' START_DTTM
FROM SomeTable
UNION ALL
SELECT Name, 'ended', END_DT
FROM SomeTable
答案 1 :(得分:0)
试试这个:
SELECT Name, Action, Action_Date FROM (
SELECT Name, 'Joined' as Action, JOIN_DT as ACTION_DATE FROM TableA
UNION ALL
SELECT Name, 'Started', START_DT FROM TableA
UNION ALL
SELECT Name, 'Ended', END_DT FROM TableA)
ORDER BY Name;