Exforsys
+ Reply to Thread
Results 1 to 7 of 7

Oracle queries

This is a discussion on Oracle queries within the Oracle Database forums, part of the Database category; Dear friends i am in trouble can u plzzzz help me .i have 2 questions plz sove it 1- i ...

  1. #1
    ashish_ietk2000 is offline Junior Member Array
    Join Date
    Jan 2007
    Answers
    1

    Oracle queries

    Dear friends
    i am in trouble can u plzzzz help me .i have 2 questions plz sove it

    1- i have to use if condition with select statement
    2-make such type of query so that it deletes duplicate data in a table

    Thanx
    Ashish Pandey


  2. #2
    srinu.oracle is offline Junior Member Array
    Join Date
    Jan 2007
    Answers
    1

    Answer for second question

    To eleminate duplicate rows use this one and try it.
    select distinct job from emp;
    useing decode function we can implement the if condition in select statement.i don't know exact quary i will send tomarrow.


  3. #3
    vanimohankumar is offline Junior Member Array
    Join Date
    Jan 2007
    Answers
    2
    hello friend

    for deleting duplicate values in table use following query

    delete * from table_name
    where row_id < (select max(row_id) from table_name
    group by column_name);

    this query wll delete the duplicates rows


  4. #4
    Angela is offline Member Array
    Join Date
    Apr 2006
    Answers
    85
    Ashish did you try the suggestions given by our friends here in this thread. What is the result? Is your problem solved? Let us know so that we could know your status of query


  5. #5
    Abdul Qadeer is offline Junior Member Array
    Join Date
    Apr 2007
    Answers
    2

    Let me know if it works in deleting duplicate rows.

    1. In order to user it in if statement you have to make procedure,or cursor
    then use this syntax in then condition.

    delete from table_name where rowid not in (select max(rowid)
    from table_name group by column_name); (not null column).


  6. #6
    psiva_exforsys is offline Junior Member Array
    Join Date
    Jun 2007
    Answers
    8

    Delete duplicate rows and decode function in SQL query

    we can delete the duplicate records from the table using with the below querys

    delete ename from emp a where rowid < (select min(rowid) from emp b
    where a.rowid<=b.rowid);


    Decode function:

    we can select the employee based on the sex(male (M) and Female(F) using decode function

    select decode(M,'Male',1,
    decode (F,'Female,0) from emp;

    Syntax for decode like if...than...else

    IF s = search1
    THEN result1
    ELSE default
    Exercises


    Regards,
    Siva.P
    Bangalore


  7. #7
    anilkumar2010's Avatar
    anilkumar2010 is offline know nothing Array
    Join Date
    Oct 2011
    Location
    amerpet
    Answers
    7
    both are same but when u r in learning stage use select statement with DISTINCT keyword


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...