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

Group By, needing to exclude a value in group by

$
0
0

Hi I'm selecting values from a table, but I need to select and include a column but it must not be included in the group by. If I include it in the group by 4 results are returned. I only need it to return 3 values, but I can only achieve this if I exclude it from the group by but then the column obviously is not included in the result anymore. How would I modify my select statement to include the column Stats.Custom1 but not have it in the groupby

SELECT

ClientName,  
Stats.ClientID AS ClientID,
Stats.Discription AS SERVICE,
MAX(Stats.DateLastRun) AS DateRun,
Max(STATS.ID) AS ID,
Stats.Custom1
FROM Stats JOIN Clients ON Clients.ID = Stats.ClientID
Group by 
Stats.Custom1,
ClientName,
Stats.ClientID,
Stats.Discription


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>