Re: Convert Specific Row Data into Columns
Thanks, I think I'm getting closer. I tried:
SELECT
Name,
( CASE event WHEN 'Start' THEN time ELSE 0 END ) AS 'Start',
( CASE event WHEN 'Stop' THEN time ELSE 0 END ) AS 'Stop',
( CASE event WHEN 'Event1' THEN 1 ELSE 0 END ) AS 'Event1',
( CASE event WHEN 'Event2' THEN 1 ELSE 0 END ) AS 'Event2'
from (
SELECT
name, time, event, COUNT(*) AS Data
FROM aTable as stats
GROUP BY name, event) as stats;
and the output is:
Name Start Stop Event1 Event2
Bob 0 0 1 0
Bob 00:19:47 0 0 0
Bob 0 00:17:57 0 0
Steve 0 0 1 0
Steve 0 0 0 1
Steve 00:19:53 0 0 0
Steve 0 00:19:45 0 0
How do I collapse the 3 Bob rows and 4 Steve rows into a single row each?
Subject
Written By
Posted
December 06, 2016 12:16PM
December 06, 2016 01:05PM
Re: Convert Specific Row Data into Columns
December 06, 2016 04:31PM
December 06, 2016 04:47PM
December 06, 2016 08:41PM
December 07, 2016 01:06AM
December 07, 2016 02:19PM
December 07, 2016 02:30PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.