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

Choose the longest character in specific Column

$
0
0

Hi guys,

My query returns as below:

Computer NameMakeModelS/NOU Name
Hostname1Dell Inc.Latitude E6400A123456DOMAIN.LOCAL/Computer
Hostname1Dell Inc.Latitude E6400A123456DOMAIN.LOCAL/Computer/OS
Hostname1Dell Inc.Latitude E6400A123456DOMAIN.LOCAL/Computer/Windows7

Now that was duplicate value for Hostname1.

I wanted the result for Hostname 1 to be unique, which only to display the longest character under column 'OU Name'

I'm using max as the following but the results didn't change much:

select
Info.Computer_Name as 'Computer Name',
Info.Make as 'Make',
Info.Model as 'Model,
Info.Serial_Number as 'S/N',
max (Info.OU_Name) as 'OU Name'

from
ComputerInformation as Info

group by
Info.Computer_Name,
Info.Make,
Info.Model,
Info.Serial_Number,
Info.OU_Name

Please help me to achieve the desired results.

Thank you very much in advanced!



---Pat




Viewing all articles
Browse latest Browse all 23857

Trending Articles



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