Duplicate data in column in Oracle 10g Express Edition

220 pts.
Tags:
Oracle 10g
Oracle 10g administration
Oracle 10g Express
Oracle administration
I hava created a column like: 
                             create table pen(no integer, name varchar(30))
It contains the following data:
            NO NAME
             1         reynolds
             2         reynolds
             2         super
             3         cello
             4         cello
             4    hh
 select distinct no, name from pen      -this is working fine
 but the following query results error:
                               select distinct(no, name) from pen
error is :- ORA-00907: missing right parenthesis


Software/Hardware used:
Oracle 10 g express edition

Answer Wiki

Thanks. We'll let you know when a new response is added.

There is no need to use parenthesis.

This will produce the results you expect:

<pre>select distinct no, name from pen</pre>

The DISTINCT keywork eliminates duplicate <b>rows </b>from the results of the query. It applies to all of the columns included in the select list.

You can use parenthesis with one column, but when including more than one, the ORA-00907 error is generated.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    "This will produce the results you expect" I might be wrong with this, becase we don't really know what are the results you expect. The query I provided will return all of the rows in the PEN table, because the is no no+name combination duplicated. Feel free to add more details or ask for further help if needed.
    70,190 pointsBadges:
    report
  • Prcvjr
    will this query eleminates duplicate rows or duplicate data in a column?
    220 pointsBadges:
    report
  • carlosdl
    "will this query eleminates duplicate rows or duplicate data in a column?" I'm sure you can try it, and see the results. One of the best ways to learn is trying things. It will eliminate duplicate rows (i.e. the row will be filtered out only if the complete row is duplicate)
    70,190 pointsBadges:
    report
  • Kccrosser
    DISTINCT excludes duplicate "rows" from the result set where ALL the columns in the result set contain duplicate data.
    select DISTINCT NAME from PEN
    This will return the unique NAME values from the table.
    select DISTINCT NO, NAME from PEN
    This will probably NOT be what you want, since if the NO field is not duplicated in the data records, then all of the result rows will be unique - no duplicates. In your example set from the question, ALL the rows shown would be returned.
    3,830 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following