Answered Questions

  • How to get number of days using SQL ?

    I have table .. like EMPNO Ename DOB ------------------------------------ 1 you 1-jan-2011 2 Me 28-jan-2011 tel me the query for no.of days different from.. two dates of column DOB.? Thanks in advance. Sateesh

  • Get Numeric Values only using SQL ?

    I have table with one column. type varchar.. PHONE --------------- 99samn44423m44 8034skdf3453a2 909090abc4567d i want to get numeric values.. i mean my output will be PHONE --------------- 994442344 80343453a2 9090904567 thanks in advance.. Sateesh

    Ganezh

    • Apr 20th, 2016

    Code
    1. SELECT REGEXP_REPLACE(AB12CD34EF,A|B|C|D|E|F, ) FROM DUAL;

    Krishna

    • Mar 30th, 2016

    Code
    1. SELECT REGEXP_REPLACE(<Column Name>,[A-Za-z]) FROM <Table Name>;

  • how to get the prime number rows from table ie like1,3,5,7,11

    VIJAY SHARMA

    • Sep 24th, 2012

    Code
    1.  
    2. SELECT SEQNO "PRIME NUMBERS"
    3. FROM(
    4.      SELECT SEQNO
    5.      FROM(
    6.           SELECT ROWNUM SEQNO
    7.           FROM ALL_OBJECTS
    8.           GROUP BY ROWNUM
    9.           HAVING ROWNUM <= &GIVENNUM
    10.          ),
    11.          (
    12.           SELECT ROWNUM SEQNO2
    13.           FROM ALL_OBJECTS
    14.           WHERE ROWNUM <= &GIVENNUM
    15.          ) A2
    16.     GROUP BY CUBE(SEQNO,SEQNO2)
    17.     HAVING GROUPING_ID(SEQNO,SEQNO2) = 0 AND SEQNO >= SEQNO2 AND
    18.     MOD(SEQNO,SEQNO2) = 0
    19.     )
    20. GROUP BY SEQNO
    21. HAVING COUNT(*) IN(1,2)
    22. ORDER BY SEQNO;

    KARRTHIK

    • Dec 3rd, 2011

    "plsql n number; i number; counter number; begin n:=&n; i:=1; counter:=0; if n=1 then dbms_output.put_line('1 is a prime No.'); else if n=2 ...