If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > how to retrieve distinct values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-17-04, 07:10
rahman rahman is offline
Registered User
 
Join Date: Aug 2003
Posts: 6
Question how to retrieve distinct values

hi friends

i want to retrieve distinct values from 2 columns at the same times eg.

mrn NameInEng NameInFrch

11 rockey rrrrrrr
22 ruxy rxrxrx
33 rockey rrrrrrr
44 ruxy rxrxrx
55 ruxy rxrxrx
66 tony dummy
77 sony
88 tony

column NameInEng is not null and NameInFrch may be null or may contain blanks or some dummy values

output should be like:-

NameInEng NameInFrch

rockey rrrrrrr
ruxy rxrxrx


NOTE:- query should display even exists single time but with the relevant script(eng/frch),
as i mentioned column NameInEng is not null and NameInFrch may be null or may contain blanks or some dummy values.
the result should ignore any DUMMY or BLANKS/NULL values of column NameInFrch.

i mean the result should be in unique values which have only relevant script Eng/Frch(ommiting dummy/null/blanks)
e.g. not required the following

tony dummy
sony
tony


please help me

with warm regards

rahman
Reply With Quote
  #2 (permalink)  
Old 04-17-04, 07:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
select distinct NameInEng, NameInFrch
from yourtable
where NameInFrch is not null
and NameInFrch > ''
and NameInFrch <> 'DUMMY'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-17-04, 07:27
rahman rahman is offline
Registered User
 
Join Date: Aug 2003
Posts: 6
how to retrieve distinct values

hi Boss,
how r u?
thanx for ur immidiate reply,
i tried but no row returned though huge rows are exist
1 SELECT DISTINCT fname,afname from mpi
2 where afname is not null and
3 afname > '' and
4* afname<>'ترجمة'
SQL> /

no rows selected

please guide me again

thanks in advance
Reply With Quote
  #4 (permalink)  
Old 04-17-04, 07:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
how r i? i r ok, how r u?

does this produce any results?

select distinct fname,afname from mpi
where afname is not null
and afname > ''
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 04-17-04, 08:38
rahman rahman is offline
Registered User
 
Join Date: Aug 2003
Posts: 6
Quote:
Originally posted by r937
select distinct fname,afname from mpi
where afname is not null
and afname > ''

select distinct NameInEng, NameInFrch
from yourtable
where NameInFrch is not null
and NameInFrch > ''
and NameInFrch <> 'DUMMY'
Hi boss,
great.....your both the query conditionally working fine but due to incorrect input by the clerk the output is wrong...

anyway, thanks a lot n with warm regards
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On