paddycobbett
asked on
SQL Server: Can i use the distinct keyword on a portion of a column?
I have a column in a table with data such as:
001/01
001/02
002/01
002/02
I'd like to return distinct values that occur in the table on the left hand side of the "/" for slash. So the query should return the values:
001
002
I appreciate it would suggest having seperated it in 2 columns but please presume that that is not possible at this moment. The application code could do this but wanted to know if SQL could query this information.
Many thanks =)
001/01
001/02
002/01
002/02
I'd like to return distinct values that occur in the table on the left hand side of the "/" for slash. So the query should return the values:
001
002
I appreciate it would suggest having seperated it in 2 columns but please presume that that is not possible at this moment. The application code could do this but wanted to know if SQL could query this information.
Many thanks =)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys =)
SELECT Distinct SUBSTRING('001/01',1,PATIN