cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to get one row back per ID? Select Distinct is not working.

dshao
New Contributor II

Here is the current output for my select statement. I would like it to return one row for this jobsubmissionid, where it selects only the non-zero value from each of the rows. I tried using

SELECT DISTINCT jobsubmissionid

but it still returned 5 rows.

image

1 ACCEPTED SOLUTION

Accepted Solutions

UmaMahesh1
Honored Contributor III

Is that the complete query you are using. I'm guessing that you are using select distinct * from table_name.

If you wanted a individual column distinct value you have to apply a filter condition or aggregate the data accordingly.

Anyways, a complete pic with the query would help to check out what you are doing..

Cheers.

View solution in original post

2 REPLIES 2

UmaMahesh1
Honored Contributor III

Is that the complete query you are using. I'm guessing that you are using select distinct * from table_name.

If you wanted a individual column distinct value you have to apply a filter condition or aggregate the data accordingly.

Anyways, a complete pic with the query would help to check out what you are doing..

Cheers.

dshao
New Contributor II

That helped. I was using too many columns in the

GROUP BY

Once I removed all columns except for jobsubmissionid, it returned 1 row.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.