troubleshooting Question

SQL Query - Distinct with Concatenated Columns

Avatar of Jimbo99999
Jimbo99999Flag for United States of America asked on
Microsoft SQL Server
3 Comments1 Solution200 ViewsLast Modified:
Good Day Experts!

I am in need of assistance with a SQL query for use in my VB.net application.  I am getting first name and last name from seperate columns in a table. Then I had to concatenate the two seperated by a comma to show Last, First in my combo box.  

The trouble lies in the SQL table...there are at times 2 records with the same first and last name as a result of DataEntry duplication.  So, I am seeing 2 rows of Smith, Bob in my combobox.  

How can I get only one to be returned back in my query results? I tried looking at Distinct but could not get it to work.  

Here is my query that works but shows duplicates:

Select lname + ',' + fname as name from Login where corporation like '%Contech%'
                                        order by name asc

Thanks,
jimbo99999
ASKER CERTIFIED SOLUTION
Anil Golamari
Full Stack Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros