![]() | |
#21
| |||
| |||
|
|
So the problem I have is that there is some duplicate data in TABLE1 and TABLE2, but TABLE1 data always has more data available then in TABLE2, so that is how I know if there is a duplicate to take the first row. |
#22
| |||
| |||
|
|
Let me expand a little on what I am actually doing, I provided a small example in the original post as I thought there might be a simple way to select the first distinct row based on one column. Without specifics, here is how my query is structured: SELECT DISTINCT(ID), NAME, SSN FROM ( * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE1 * * *UNION ALL * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE2 ) So the problem I have is that there is some duplicate data in TABLE1 and TABLE2, but TABLE1 data always has more data available then in TABLE2, so that is how I know if there is a duplicate to take the first row. |
#23
| |||
| |||
|
|
Let me expand a little on what I am actually doing, I provided a small example in the original post as I thought there might be a simple way to select the first distinct row based on one column. Without specifics, here is how my query is structured: SELECT DISTINCT(ID), NAME, SSN FROM ( * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE1 * * *UNION ALL * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE2 ) So the problem I have is that there is some duplicate data in TABLE1 and TABLE2, but TABLE1 data always has more data available then in TABLE2, so that is how I know if there is a duplicate to take the first row. |
#24
| |||
| |||
|
|
Let me expand a little on what I am actually doing, I provided a small example in the original post as I thought there might be a simple way to select the first distinct row based on one column. Without specifics, here is how my query is structured: SELECT DISTINCT(ID), NAME, SSN FROM ( * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE1 * * *UNION ALL * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE2 ) So the problem I have is that there is some duplicate data in TABLE1 and TABLE2, but TABLE1 data always has more data available then in TABLE2, so that is how I know if there is a duplicate to take the first row. |
#25
| |||
| |||
|
|
Let me expand a little on what I am actually doing, I provided a small example in the original post as I thought there might be a simple way to select the first distinct row based on one column. Without specifics, here is how my query is structured: SELECT DISTINCT(ID), NAME, SSN FROM ( * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE1 * * *UNION ALL * * *SELECT DISTINCT(ID), NAME, SSN FROM TABLE2 ) So the problem I have is that there is some duplicate data in TABLE1 and TABLE2, but TABLE1 data always has more data available then in TABLE2, so that is how I know if there is a duplicate to take the first row. |
![]() |
| Thread Tools | |
| Display Modes | |
| |