You are on page 1of 1

1) Write a query to replace "J" into "BL" on the string "JACK and JUE"

------SELECT REPLACE( 'JACK and JUE', 'J', 'BL' ) FROM dual;

2) Write a query to get only "India" from the string "I am from India"

-------SELECT SUBSTR( 'I am from India',11 ) FROM dual;


OR
-------SELECT SUBSTR('I am from India',INSTR( 'I am from India','India' )) FROM
dual;

3) Write a query to find the length of the string "Oracle is useful"

-----SELECT LENGTH('Oracle is useful') FROM dual;


OR
------DECLARE
Test_String string(50) := 'Oracle is useful';
BEGIN
dbms_output.put_line(LENGTH(Test_String));
END;

4) Write a query to get the date of the last day of the month

-----SELECT LAST_DAY(SYSDATE) FROM dual;

5) Write a query to find out the month between "01/01/2020" and "01/05/2021"

------SELECT
MONTHS_BETWEEN(TO_DATE('01/01/2020','DD/MM/YYYY'),TO_DATE('01/05/2021','DD/MM/YYYY'
)) FROM dual;

6) Write a query to find the year from the date "01/01/2020" by using extract
function

-------SELECT EXTRACT(YEAR FROM TO_DATE('01/01/2020','DD/MM/YYYY')) FROM dual;

7) Write a query to find a 5 letter of the string "HCL Technologies"

------SELECT SUBSTR( 'HCL Technologies',5,1 ) FROM dual;

8) Write a query to add 5 months from current date

--------SELECT ADD_MONTHS(CURRENT_DATE, 5 ) FROM dual;

9) Find out first day of current year

-------SELECT TRUNC(SYSDATE ,'YEAR') FROM DUAL;

10) Write a query to get the day of the date "01/01/2021"

-------SELECT TO_CHAR( TO_DATE('01/01/2021','DD/MM/YYYY'), 'DAY' ) FROM dual;

You might also like