I need this table:
Be this: (edit it as an image using paint to show as an example)
The data will always have the same 'serverName', DATE and TIME in common
What you must do is group by certain columns. In this case, for serverName
, Date
and Time
, for example, this query would return a result like the one you expect:
with
Datos as (
select 16 idse, 'LSTKAG72544' serverName, cast('20180928' as date) [DATE], CAST('17:09:59' as time) [TIME], null SQLBrowser, 'Running' W3SVC, null wscsvc
union all
select 17 idse, 'LSTKAG72544' serverName, cast('20180928' as date) [date], CAST('17:09:59' as time) [time], null SQLBrowser, null W3SVC, 'Running' wscsvc
union all
select 18 idse, 'LSTKAG72544' serverName, cast('20180928' as date) [date], CAST('17:09:59' as time) [time], 'Running' SQLBrowser, null W3SVC, null wscsvc
)
select min(idse) idse
, serverName
, [DATE]
, [TIME]
, min(SQLBrowser) SQLBrowser
, min(W3SVC) W3SVC
, MIN(wscsvc) wscsvc
from Datos
group by serverName, [DATE], [TIME];
Takes the records to a Database and then performs the query with the GROUP BY statement and you put it in the table.
Welcome to StackoverFlow in Spanish, sorry but use the Translator to answer you ...