cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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.

Uma Mahesh D

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.

Uma Mahesh D

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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group