Reputation: 497
My manager asked me to change up how our cost report is displayed. She wants the data to end up looking like this:
Account | Transaction_date | Short Description
123456 | (null) | (null)
(null) | 10-31-2013 | Waste of time
(null) | 10-31-2013 | Happy Halloween
This is how the table usually displays data:
Account | Transaction_date | Short Description
123456 | 10-31-2013 | Waste of time
123456 | 10-31-2013 | Happy Halloween
Now I thought the lag
function might help me here or some sort of loop
but each time before I finished I realized data would be missing or would be displayed incorrectly. I tried looking via Google if anyone else had to do this sort of thing but came up empty handed. I guess my question is, is this even possible or can I move on to more important things?
Upvotes: 1
Views: 1033
Reputation: 24134
The best way is to do it on the CLIENT site not in the SQL statement.
Also you can do it in SQL
select Account,
Transaction_date,
Short_Description
FROM
(
select distinct 0 Ord , Account OrdAcc,
Account,
NULL Transaction_date,
NULL Short_Description
FROM T
UNION ALL
select 1 Ord , Account OrdAcc,
NULL Account,
Transaction_date,
Short_Description
FROM T
) T1
ORDER BY OrdAcc,Ord
Upvotes: 2