How to use SQL distinct
回答済みHello
I want to know how to use the SQL Distinct to get unique details. Suppose if they are two same URL's in the spreadsheet i need to get the unique one.
-
Distinct will only pull results that are truly unique, meaning if in your results you have lines akin to:
Column1,Column2,Column3
a , b , c
b , c , a
a , b , d
a , b , cand you throw
distinct
into the sql your results will look like the below:Column1,Column2,Column3
a , b , c
b , c , a
a , b , dIt sounds like you might be trying to find the odd Spreadsheet URL, I would use aCOUNT
instead ofdistinct
asCOUNT
will give you the number of times it appears. This is dependent on what other columns you have included in the results so you'll will need to be mindful of that if this is the case!Hope this helps!0The actual syntax in SQL is:SELECT
DISTINCT0I written the query in the advanced query command in the chains like SELECT DISTINCT reminder_url,status,due_at,task_type,approval_due_date. from table name but it is showing up the all the records it is not filtering the unique ones.
From the above figure I need to use distinct only on reminders_url not to all the columns like status,due_at,task_type,approval_due_date. Here in the sheet, you can see reminder_url's are same for two records. The output I am expecting should get unique reminder url.
Thanks,
Sandhya.
0Hi Sandhya Gajavalli, the DISTINCT keyword selects distinct rows for all columns being selected. Since you are including "approval_due_date" column which has unique values, both rows in your screenshot will be selected. If you exclude "approval_due_date" column from the select, then the two rows are identical and only one row would be returned.
0サインインしてコメントを残してください。
コメント
4件のコメント