Friday, December 10, 2010

Important Oracle Interview Questions

1) Deleting Duplicate Records From a Table?

delete from table_name where rowid not in (select max(rowid) from table_name group by duplicate_values_column)

see the following PRODUCT table

we can notice that there are duplicate entries for the product LUX in the prod_name column
to remove duplicate row of lux write the query as follows using the above syntax..

delete from product where rowid not in (select max(rowid) from product group by prod_name)


2) How to show  numbers in words using a query?
A) The following query is useful to display numbers in words..

Ex1:  select to_char(to_date(1250,'j'),'JSP') from dual;
         you will get the the number 1250 in words as "one thousand two hundred fifty"

Ex2: select to_char(to_date(sal,'j'),'JSP') from emp;
        you will get all the values in the "sal" column will be displayed in words...


No comments:

Post a Comment