クラシックファイルタイプは、2021年1月をもって使用不可となりました。クラシックファイルを移行するか、PDFをダウンロードすることができます。 詳細を見る

How to use SQL distinct

回答済み
0

コメント

4件のコメント

  • Isabel Messore

    Sandhya Gajavalli,

    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 , c

    and you throw  distinct  into the sql your results will look like the below:

    Column1,Column2,Column3 
    a , b , c
    b , c , a
    a , b , d
    It sounds like you might be trying to find the odd Spreadsheet URL, I would use a COUNT instead of distinct as COUNT 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!
     
    0
  • Isabel Messore
     
    Absolutely! In builder it shows up here:
     
     
    The actual syntax in SQL is:
    SELECT 
    DISTINCT
    0
  • Sandhya Gajavalli

    I 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.

    0
  • Jeff Hickey

    Hi 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

サインインしてコメントを残してください。