Link to home
Start Free TrialLog in
Avatar of Ed
EdFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Distinct Question

I have a query that returns distinct depending on EmployerID as below.

I want to ignore the .1 in my distinct statement, how do I do that?

Eg

When I do this

SELECT distinct EMPLOYERID,

Open in new window


I will get the below results.  

BUT

I would only want 1 row returned.
How do I get the distinct statement to ignore the   .1

EMPLOYER ID
0974-0001-103849
0974-0001-103849.1
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ed

ASKER

Perfect, thanks.
If position of ".1" is fixed in the employee id that it will occur only at the end for id.

You can write query like
;WITH Cte_EmpId
As
(
 SELECT distinct EMPLOYERID
)

SELECT * FROM Cte_EmpId
WHERE RIGHT(EMPLOYERID,2) <>'.1'

Open in new window


Hope it will help.