I have very simple problem that I can't solve. I need to do something like this:
select distinct * from (1, 1, 1, 2, 5, 1, 6).
Anybody can help??
Edit
The data comes as a text file from one of our clients. It's totally unformatted (it's a single, very long line of text), but it may be possible to do so in Excel. But it's not practical for me, because I will need to use these values in my sql query. It's not convenient to do so every time I need to run a query.
Available only on SQL Server 2008 and over is row-constructor in this form:
You could use
Many wrote about, among them:
Have you tried using the following syntax?
If you want to select only certain values from a single table you can try this
eg:
if you want to select from multiple tables then you must go for
UNION
.If you just want to select the values 1, 1, 1, 2, 5, 1, 6 then you must do this
Simplest way to get the distinct values of a long list of comma delimited text would be to use a find an replace with UNION to get the distinct values.
Applied to your long line of comma delimited text
UNION SELECT
SELECT
in front of the statementYou now should have a working query
I know this is a pretty old thread, but I was searching for something similar and came up with this.
Given that you had a comma-separated string, you could use
string_split
This should return
String split takes two parameters, the string input, and the separator character.
you can add an optional where statement using
value
as the column nameproduces
Use the SQL
In
functionSomething like this:
Works a treat in ArcGIS