Vote count:
0
I have a table that store many values that are 'different' by a column (TYPE) value that could be "A", "B" or "C".
When i perform a select to retrieve values, i need to perform some operations like apply a subquery to retrieve an alias value if TYPE equals "A" that is different from subquery to TYPE "B".
Now i have 2 queries: one for type "A" and another for type "B". I would like to put this queries together but i'm not finding a way how to do it.
Type "A"
SELECT distinct(l.ProcessId),
(SELECT Date from Log lt WHERE lt.ProcessId = l.ProcessId and lt.Message like '%SENDING%') as DateStart,
(SELECT Date from Log lt WHERE lt.ProcessId = l.ProcessId and lt.Message like '%DONE%') as DateEnd,
DATEDIFF(ss, (SELECT Date from Log lt WHERE lt.ProcessId = l.ProcessId and lt.Message like '%SENDING%'), (SELECT Date from Log lt WHERE lt.ProcessId = l.ProcessId and lt.Message like '%DONE%')) as Duration
FROM notifier.Log l where l.Who = 'QueryString' and l.Type = 'A'
Type "B"
SELECT distinct(l.ProcessId),
Date as DateStart,
Date as DateEnd,
DATEDIFF(ss, Date, Date) as Duration
FROM notifier.Log l where l.Type = 'B';
How can i perform an unique select to retrieve type "A" and "B"?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire