order of producing result when distinct is used | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

order of producing result when distinct is used

when we use distinct like select distinct column_name from table_name how the order it produces result c1 p1 10 1-Sep-16 c2 p3 20 18-Mar-17 c5 p5 30 20-Dec-16 c3 p2 45 1-Sep-16 c4 p4 15 1-Sep-16 c7 p3 22 18-Mar-17 c1 p2 23 1-Sep-16 c2 p1 33 -Jul-17 mean when searching from top of table does p1 0f c1 will be in result or p1 of c2 will be in result

9th Jan 2020, 10:32 AM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar
6 Answers
+ 1
p1 will be in the result only once, it does not matter based on which line, because the other columns are not shown. You can select distinct column1, column2 Then all unique combinations of the two columns are retrieved.
9th Jan 2020, 11:46 AM
Tibor Santa
Tibor Santa - avatar
+ 1
If you use distinct on multiple columns, then the result will be grouped by all those columns. Anyway you can control the order of the result lines with ORDER BY clause. I could probably give a more helpful answer if you formulate your question more precisely :)
9th Jan 2020, 2:03 PM
Tibor Santa
Tibor Santa - avatar
+ 1
lucky no. You can only use distinct immediately after the select keyword.
10th Jan 2020, 12:38 PM
Tibor Santa
Tibor Santa - avatar
0
Here other columns are print But if there is a situation of printing all then which will be print
9th Jan 2020, 12:05 PM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar
0
Ok bro tq
10th Jan 2020, 3:54 PM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar
- 1
Just like SELECT * from class_name where DISTINCT column_name
10th Jan 2020, 12:08 PM
Lakshmi Reddy Sanikommu
Lakshmi Reddy Sanikommu - avatar