![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Suppose I have the following table... name employeeId email -------------------------------------------- Tom 12345 t... (AT) localhost (DOT) com Hary 54321 Hary 54321 h... (AT) localhost (DOT) com I only want unique employeeIds return. If I use Distinct it will still return all of the above as the email is different/missing. Is there a way to query in SQL so that only distinct employeeId is returned? no duplicates. I wouuld like to say WHERE no blank fields are present to get the right row to return. Many thanks Yas |
#3
| |||
| |||
|
|
On Aug 21, 10:04 am, Yas <yas... (AT) gmail (DOT) com> wrote: Hello, Suppose I have the following table... name employeeId email -------------------------------------------- Tom 12345 t... (AT) localhost (DOT) com Hary 54321 Hary 54321 h... (AT) localhost (DOT) com I only want unique employeeIds return. If I use Distinct it will still return all of the above as the email is different/missing. Is there a way to query in SQL so that only distinct employeeId is returned? no duplicates. I wouuld like to say WHERE no blank fields are present to get the right row to return. Many thanks Yas Which row for Hary do you want to be returned? The one without an email address or the one with the email address? |
#4
| |||
| |||
|
|
On 21 Aug, 11:20, stephen <m0604... (AT) googlemail (DOT) com> wrote: On Aug 21, 10:04 am, Yas <yas... (AT) gmail (DOT) com> wrote: Hello, Suppose I have the following table... name employeeId email -------------------------------------------- Tom 12345 t... (AT) localhost (DOT) com Hary 54321 Hary 54321 h... (AT) localhost (DOT) com I only want unique employeeIds return. If I use Distinct it will still return all of the above as the email is different/missing. Is there a way to query in SQL so that only distinct employeeId is returned? no duplicates. I wouuld like to say WHERE no blank fields are present to get the right row to return. Many thanks Yas Which row for Hary do you want to be returned? The one without an email address or the one with the email address? basically 1 that doesn't have any fields missing.... cheers |
#5
| |||
| |||
|
|
On 21 Aug, 11:20, stephen <m0604... (AT) googlemail (DOT) com> wrote: On Aug 21, 10:04 am, Yas <yas... (AT) gmail (DOT) com> wrote: Hello, Suppose I have the following table... name employeeId email -------------------------------------------- Tom 12345 t... (AT) localhost (DOT) com Hary 54321 Hary 54321 h... (AT) localhost (DOT) com I only want unique employeeIds return. If I use Distinct it will still return all of the above as the email is different/missing. Is there a way to query in SQL so that only distinct employeeId is returned? no duplicates. I wouuld like to say WHERE no blank fields are present to get the right row to return. Many thanks Yas Which row for Hary do you want to be returned? The one without an email address or the one with the email address? basically 1 that doesn't have any fields missing.... cheers |
#6
| |||
| |||
|
|
Hello, Suppose I have the following table... name employeeId email -------------------------------------------- Tom 12345 t... (AT) localhost (DOT) com Hary 54321 Hary 54321 h... (AT) localhost (DOT) com I only want unique employeeIds return. If I use Distinct it will still return all of the above as the email is different/missing. Is there a way to query in SQL so that only distinct employeeId is returned? no duplicates. I wouuld like to say WHERE no blank fields are present to get the right row to return. Many thanks Yas Which row for Hary do you want to be returned? The one without an email address or the one with the email address? basically 1 that doesn't have any fields missing.... cheers SELECT * from table where name<>"" and employeeId<>0 and email<>""; |
#7
| |||
| |||
|
|
SELECT * from table where name<>"" and employeeId<>0 and email<>""; Just a note: Please, no double quotes for string constants, use single quotes. Double quotes are reserved for "delimited identifiers" as defined by the SQL Standard and supported by MS SQL Server. |
![]() |
| Thread Tools | |
| Display Modes | |
| |