I would like to know whether its possible to get a list of distinct values in a SQLite Column without ordering them.
I tried following query. But it automatically orders the unique text into ascending order.
SELECT DISTINCT column FROM table;
Ex.
Column
Mathew Mathew John John John Numbers Numbers
Result
John Mathew Numbers
But I would like it not to be ordered. Would like it in Mathew, John, Numbers
Thanks.
Introduction to SQLite SELECT DISTINCT clause In this syntax: First, the DISTINCT clause must appear immediately after the SELECT keyword. Second, you place a column or a list of columns after the DISTINCT keyword. If you use one column, SQLite uses values in that column to evaluate the duplicate.
Without a transformation, a statement that contains both DISTINCT and ORDER BY would require two separate sorting steps-one to satisfy DISTINCT and one to satisfy ORDER BY. (Currently, Derby uses sorting to evaluate DISTINCT.
Adding the DISTINCT keyword to a SELECT query causes it to return only unique values for the specified column list so that duplicate rows are removed from the result set.
Yes, DISTINCT works on all combinations of column values for all columns in the SELECT clause.
What order do you want?
If you want to get the values in the order of first appearance you can do:
select distinct column from table order by min(rowid);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With