Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select group by query

$
0
0

I'm wanting to exclude 3 values from the group by clause within a select statement, how would I achieve this with the following select statement:

SELECT Distinct 
ClientName AS Client,
Service AS Serv,
MAX(Stat.DateLastRun) AS DateRun,
(Files1Hour) as '1 Hour',
(Files3Hour) as '3 Hour',
(Files6Hour) as '6 Hour',
(NoMatch) as 'No Match'
FROM Stat
Group by Service,ClientName

Basically I want the rows with distinct Client Names (ClientName) and Services (Service) with the biggest date.


Viewing all articles
Browse latest Browse all 23857

Trending Articles