7 Replies Latest reply: Apr 2, 2013 7:53 AM by jeneesh RSS

    Reg: Emp Base table

    948062
      Hi All,

      I want to get result from Emp table of oracle.

      i have two queries:

      1) I want to get Last Three Character of ename of 14 records from emp table.

      2) Want to get Hiredate records from emp table in Month wise Descending Order.





      Thanks
        • 1. Re: Reg: Emp Base table
          jeneesh
          945059 wrote:
          Hi All,

          I want to get result from Emp table of oracle.

          i have two queries:
          Home work..?
          >
          1) I want to get Last Three Character of ename of 14 records from emp table.
          Search for SUBSTR function.


          2) Want to get Hiredate records from emp table in Month wise Descending Order.
          check TO_CHAR
          • 2. Re: Reg: Emp Base table
            948062
            Can you give me the query for my requirement. i tried but not getting result.




            Thanks
            • 3. Re: Reg: Emp Base table
              jeneesh
              945059 wrote:
              Can you give me the query for my requirement. i tried but not getting result.
              Can you post what have you tried?

              And what issue you face?
              • 4. Re: Reg: Emp Base table
                908002
                Hi All,

                I want to get result from Emp table of oracle.

                i have two queries:

                1) I want to get Last Three Character of ename of 14 records from emp table.
                select substr(ename,-3,3) from emp;
                2) Want to get Hiredate records from emp table in Month wise Descending Order.
                select ename,hiredate from emp
                order by to_char(hiredate,'mm');
                • 5. Re: Reg: Emp Base table
                  jeneesh
                  Kiran wrote:
                  Hi All,

                  I want to get result from Emp table of oracle.

                  i have two queries:

                  1) I want to get Last Three Character of ename of 14 records from emp table.
                  select substr(ename,-3,3) from emp;
                  Why -3 and 3 ?
                  2) Want to get Hiredate records from emp table in Month wise Descending Order.
                  select ename,hiredate from emp
                  order by to_char(hiredate,'mm');
                  This will not order in month wise desc - It will do ASC sort

                  Anyhow, OP did not provide expected output..
                  • 6. Re: Reg: Emp Base table
                    S10390
                    1)I want to get Last Three Character of ename of 14 records from emp table.
                    select substr(ename,-3,3) from emp;
                    Why -3 and 3 ?
                    Because want to get the last three characters of ename. Refer
                    http://docs.oracle.com/javadb/10.8.2.2/ref/rrefsqlj93082.html

                    And
                    2) Want to get Hiredate records from emp table in Month wise Descending Order.
                    select ename,hiredate from emp
                    order by to_char(hiredate,'mm');
                    add desc in second query
                    select ename,hiredate,to_char(hiredate,'mm') from emp order by to_number(to_char(hiredate,'mm')) desc;
                    for reference..
                    http://psoug.org/reference/convert_func.html

                    Edited by: S10390 on Apr 2, 2013 6:21 PM
                    • 7. Re: Reg: Emp Base table
                      jeneesh
                      S10390 wrote:
                      1)I want to get Last Three Character of ename of 14 records from emp table.
                      select substr(ename,-3,3) from emp;
                      Why -3 and 3 ?
                      Because want to get the last three characters of ename.
                      For that -3 is enough.. ;)

                      And
                      2) Want to get Hiredate records from emp table in Month wise Descending Order.
                      select ename,hiredate from emp
                      order by to_char(hiredate,'mm');
                      add desc in second query
                      select ename,hiredate,to_char(hiredate,'mm') from emp order by to_number(to_char(hiredate,'mm')) desc;
                      to_number(to_char(hiredate,'mm')) desc => That looks better..