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.
A technique that has worked for me is to query a table that you know has a large amount of records in it, including just the Row_Number field in your result
will return a result set of 10000 records from 1 to 10000, use this within another query to give you the desired results
In general :
In your case :
PostgreSQL gives you 2 ways of doing this:
or
using array approach you can also do something like this:
This works on SQL Server 2005 and if there is maximal number:
Another way that you can use is a query like this:
If you need an array, separate the array columns with a comma: