How to use this query in oracle?

Hi Sir,

I use a SQL query that is

declare @date date ='2012-10-25', @date1 varchar (5)
Set @date1 = DATEPART (W, @date)
impression @date1

that its value means day 25 oct 5 back Thursday it is checking and counting from Sunday in this week so the result is 5 next.

and storing in @date1

the same result I want in oracle.

Thank you

Try this...

/* Formatted on 10/5/2012 10:22:34 AM (QP5 v5.163.1008.3004) */
SELECT TO_CHAR (TO_DATE ('2012-10-25', 'yyyy-mm-dd'), 'D') FROM DUAL;

gives

5

HTH
Vanessa B.

Tags: Database

Similar Questions

  • How to use this API in Oracle ApEx

    I searched for a few days now, trying to find how to use this or any API in the ApEx.

    https://translate.Google.nl/translate?HL=NL & SL = NL & TL = in & u = http % 3A % 2F % www.pstcd.nl%2Fdocumentatie%2F 2F

    This sounds noobish, but I have no idea how to use. If anyone can help or give me some advice, it would be great.

    Hello

    ce04a039-2da9-401b-94c9-1d3300bcbb2b wrote:

    Please change your user ID to something meaningful. Reference: Video tutorial how to change username available

    I searched for a few days now, trying to find how to use this or any API in the ApEx.

    https://translate.Google.nl/translate?HL=NL&SL=NL&TL=en&u=http%3A%2f%2Fwww.pstcd.nl%2Fdocumentatie%2f

    This sounds noobish, but I have no idea how to use. If anyone can help or give me some advice, it would be great.

    As above given RESTful Web Services Web services API, you can:

    • Use a reference to the Web Service created in the shared components and then the process based on this reference page OR
    • Use APEX_WEB_SERVICE API to call the above mentioned APEX_JSON API and web services (if you are using APEX 5.0) to parse the JSON response and then further process.

    See the following thread: access to the Web Service API

    Kind regards

    Kiran

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • How to use this "remote Taskmanager?

    Hello!

    I recently downloaded a full suite of managengine that includes remote administration like remote taskmanager, remote software inventory tools and so on... However, whenever I try to use this suite software it requires user name and password credentials. What is a credential? How should I configure one?
    Its a freeware and weight 3.71 MB. It will be great if someone can tell me how to use this software

    Link to the tutorial provided by management engine as well as the download page
    http://www.ManageEngine.com/products/free-Windows-tools/free-software-inventory-tool.html

    Please help :(

    Contact people ManageEngine to help...

    http://www.ManageEngine.com/support.html

  • How to use this site and whre to find answer to my questtion?

    How to use this site and whre to find answer to my question?

    Well, you found how to ask a question, see the answers, simply click on your profile jake coll at the top right of any page name and look at my Questions.
     
     
  • I lost my Muse files, when my computer broke down. went to my domain, all of my info Web sites host goDaddy. in a file zip (websitebackup3.zip) how to use this Info. to get my Web site up?

    My name is KennyD

    I lost my Muse files, when my computer broke down. went to my domain, all of my info Web sites host goDaddy. in a file zip (websitebackup3.zip) how to use this Info. to get my Web site up?

    You can not. You need the .muse file.

    Always a good idea to keep backups.

  • How to use this program tril Converter PDF to word

    How to use this program tril Converter PDF to word?

    Choose Save as-> Microsoft Word-> Word Document

  • No idea how to write this query

    Hi, My Data is as below

    DocNum doc_date type of amount
    1154 15 November 11 232501.5 invoice
    200206 4 November 11 - 243672.64 credit memo
    Note flow 111 5 November 555.22 11

    Output must be

    DocNum doc_date amount Type AmountDR AmountCR
    1154 232501.5 15 November 11 Bill 232501.5
    Note credit 200206 4 November 11 - 243672.64 - 243672.64
    Note flow 111 5 November 555.22 11 555.22

    If the amount is > 0, then it must be displayed in the value of the amount to be AmountDR
    If amount < 0 then it must be displayed in the value of the sum amount CR



    Can help how to write this query
    with sample_table as (
                          select 1154 Docnum,date '2011-11-15' doc_date,232501.5 Amount,'Invoice' type from dual union all
                          select 200206,date '2011-11-04',-243672.64,'Credit Memo' from dual union all
                          select 111,date '2011-11-05',555.22,'Debit Memo' from dual
                         )
    select  Docnum,
            doc_date,
            Amount,
            type,
            case
              when Amount >= 0 then Amount
            end AmountDR,
            case
              when Amount < 0 then Amount
            end AmountCR
      from  sample_table
    /
    
        DOCNUM DOC_DATE      AMOUNT TYPE          AMOUNTDR   AMOUNTCR
    ---------- --------- ---------- ----------- ---------- ----------
          1154 15-NOV-11   232501.5 Invoice       232501.5
        200206 04-NOV-11 -243672.64 Credit Memo            -243672.64
           111 05-NOV-11     555.22 Debit Memo      555.22
    
    SQL> 
    

    SY.

  • How to use this class

    The following code is a class I want to use (Arc.as), but it doesn't have a constructor function (i.e. public void Arc()). How to use this class in Flex? I also placed the code I thought I could use.

    Yes, in the example of the arc, in the change of loop(e:Event):
    removeChild (sp);
    TO:
    container.removeChild (sp);

  • How to write this query?

    Hi people,

    I need to get a query in which a set of records, I get ONLY those which previous registry has a field with a value to this topic. Other values, the field can contain are not necessary.

    I know that sounds easy but... I can't get it.

    So, for Oracle 10 g 2... Here's my query:

    SELECT a.person_id, a.person_status, a.message_id, a.order_id

    OF t_HR one

    WHERE a.person_status = "rejected".

    AND a.id >

    (SELECT max (b.id)

    OF t_HR b

    WHERE b.person_id = a.person_id

    and b.order_id = a.order_id

    AND b.person_status! "revised =".

    B.ID AND < a.id)

    ORDER BY desc a.id

    Let me explain:

    1 - HR table is a table of people. These people has serveral STATUS.

    2 - ID is a sequential (each www.voyages-sncf.com has a different identification number).

    3 - the application must get THAT all people "rejected".

    4. - However, (subquery) I need ONLY those that previous register (the second register) holds a status of "OK". If the person holds a "revised" status he's not, he should be the next register (the third)

    5.-L' ORDER ID DESC, so is the first register must have a STATUS = "rejected" and the second a 'OK '.  IF the second register = "revised", then the third register must be 'OK '. And I need this query.

    HOW DO?

    My problem: the subquery gives you previous register of the same guy, but... it does not give you the value of the State, I need, which is 'OK '.

    I tried to add to the subquery...

    SELECT max (b.id)

    OF mod_human_resource b

    WHERE b.person_id = a.person_id

    and b.order_id = a.order_id

    AND b.person_status = 'OK '.

    AND b.id < a.id

    ... but if I have 5 records of that person, the first is "rejected", the second is "accepted", the third is 'new' and the fourth is 'OK'... the subquery gives you the 4th register and which is not correct for me, it must be only the second one (prior to the first State registry).

    I need to be a query, because I need to use it on a MERGER for a DWH.

    If there is another way (function, or even a procedure) to make the MERGER rather than with a request, which would be ok too. I am poor DWH knowledge.

    Thanks in advance.

    Hello

    So, you need to know if a line is the 'first' line, and you should also know what is the 'next' status, (even the 'first' and 'next' are already defined).  This sounds like a job for analytical functions.  ROW_NUMBER can tell you if a line is first or not, and LEAD can tell you what a value on the next row.

    Since you post CREATE TABLE and INSERT statements for your own table, I'll use the table scott.emp to illustrate.

    Consider these data from scott.emp:

    SELECT DeptNo

    ename

    work

    FROM scott.emp

    ORDER BY deptno

    ename DESC

    ;

    Output:

    DEPTNO ENAME JOB

    ---------- ---------- ---------

    10 MILLER CLERK

    PRESIDENT OF KING 10

    MANAGER 10 CLARK

    20 SMITH CLERK

    ANALYST SCOTT 20

    20 JONES MANAGER

    20 FORD ANALYST

    20 ADAMS CLERK

    30 WARD SALESMAN

    SELLER OF 30 TURNER

    30 MARTIN SALESMAN

    30 JAMES CLERK

    MANAGER BLAKE 30

    30 ALLEN SALESMAN

    Now, let's say we want only who know the departments where the forefront (in order descending ename) a job = 'CLERK', and the following line (also in descending by ename order) = "ANALYST" job, and we want to know the ename of the first row.  In other words, the correct output is:

    DEPTNO ENAME

    ---------- ----------

    20 SMITH

    Note that deptno = 10 is not included, even if the first task is to "CLERK." that was because the second job in deptno = 10 is the "PRESIDENT", not "ANALYST."

    Here's a way to get these results:

    WITH got_analytics AS

    (

    SELECT ename, deptno, job

    ROW_NUMBER () OVER (PARTITION BY deptno

    ORDER BY ename DESC

    ) AS r_num

    LEAD (employment) OVER (PARTITION BY deptno

    ORDER BY ename DESC

    ) AS next_job

    FROM scott.emp

    )

    SELECT deptno, ename

    OF got_analytics

    WHERE r_num = 1

    AND job = 'CLERK '.

    AND next_job = 'ANALYST '.

    ;

    I hope that answers your question.

    If this isn't the case, then, as Dan (and the FAQ forum) said, post CREATE TABLE and INSERT statements for some sample data and the exact results you want from these data.

    Post your query, based on the one I have posted more top and ponit out where he gets results.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • How to write this query in the hierarchy

    Hi gurus,

    Really need your help on this query.  Thank you very much in advance.

    SELECT
      t1.key as root_key ,
    (SELECT
          t2.unit_id AS unit_id 
          level-1 AS level ,
          t2.name,
          t2.creator
        FROM
          tab t2
          START WITH t2.unit_id       =   t1.unit_id            -----check each node as root
          CONNECT BY prior t2.unit_id = t2.parent_unit_id
    
      )
       t1.name as parent_unit_name
    FROM
      tab t1
    

    I'll write a query of the hierarchy as above, and that EACH line (node, totally more than 10200) is checked as root node to see how many sheets are accessible for her... It must be implemented in a single query.

    I know inline query should NOT return multiple rows or multiple columns, but the inline elements are necessary and can certainly be made in a correct solution.

    (env):

    Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production

    PL/SQL Release 12.1.0.2.0

    )

    Test data:

    select 1 as unit_id, null as parent_organization_unit_id, 'U1' as name from dual
    union all
    select 2, 1, 'U2' FROM DUAL
    UNION ALL
    SELECT 3, NULL, 'U3' FROM DUAL
    UNION ALL
    SELECT 4, 3, 'U4' FROM DUAL
    UNION ALL
    SELECT 5, 2, 'U5' FROM DUAL
    UNION ALL
    SELECT 6, 5, 'U6' FROM DUAL
    UNION ALL
    SELECT 7, 6, 'U7' FROM DUAL
    UNION ALL
    SELECT 8, 5, 'U8' FROM DUAL
    UNION ALL
    SELECT 9, 5, 'U9' FROM DUAL;
    

    Final result should be like this

    key unit_id,    level,   name, parent_name
    1    1    0    u1      u1
    1    2    1    u2       u1
    1    5    2     u5      u1
    1    6    3     u6      u1
    1    7    4    u7       u1
    1    8    3    u8       u1
    1    9    3     u9      u1
    2    2    0     u2       u2
    2    5    1      u5       u2
    2    6    2     u6       u2
    2    7    3      u7      u2
    2    8    2      u8       u2
    2    9    2      u9       u2
    
    

    Don't know how get you your output, it does not match your data...

    with tab as)

    Select 1 as unit_id, null as parent_organization_unit_id 'U1' as the name of double

    Union of all the

    Select 2, 1, 'U2' FROM DUAL

    UNION ALL

    SELECT 3, NULL, 'U3' FROM DUAL

    UNION ALL

    SELECT 4, 3, 'U4' FROM DUAL

    UNION ALL

    SELECT 5, 2, 'U5' OF THE DOUBLE

    UNION ALL

    SELECT 6, 5, 'U6' OF THE DOUBLE

    UNION ALL

    SELECT 7, 6, "U7" OF THE DOUBLE

    UNION ALL

    SELECT 8, 5, 'U8' FROM DUAL

    UNION ALL

    9. SELECT, 5, 'U9' FROM DUAL

    )

    Select dense_rank() key (order by connect_by_root unit_id), unit_id, level - 1 as 'LEVEL', connect_by_root name root_parent_name

    t tab

    Start with parent_organization_unit_id is null

    Connect prior unit_id = parent_organization_unit_id

    KEY UNIT_ID LEVEL ROOT_PARENT_NAME
    1 1 0 "U1".
    1 2 1 "U1".
    1 5 2 "U1".
    1 6 3 "U1".
    1 7 4 "U1".
    1 8 3 "U1".
    1 9 3 "U1".
    2 3 0 "U3".
    2 4 1 "U3".
  • How to run this query correctly?

    Hi Sir,

    I use a query that I converted from sql to oracle but in error.

    Error (4.3): PLS-00428: an INTO clause in this SELECT statement

    Here's my query:

    SELECT distinct Code pa.id, pa. Empcode Emp_ID, E.Emp_FirstName | ' ' || E.Emp_LastName Emp_Name, pa. Work Date1 date, pa. InPunch In_Punch, pa. OutPunch Out_Punch, pa.approve, ls. Leave_Status_text StatusText, NVL (pt.punchtype, 'day') JOIN employee E ON PunchForApproval pa e.Emp_ID punchtype is pa. Empcode LEFT JOIN Leave_status ls TO ls. Leave_Status_id = pa.approve LEFT JOIN punchtype pt ON pt.id = pa. STATUS
    WHERE E.Emp_ID IN (SELECT Emp_id FROM employee) ORDER BY pa.id DESC;

    Thank you

    Hello
    You run this in a PL/SQL procedure? If so, what the procedure called the request?

    Also, did you see the error even if you add a space to the request here.

    WHERE E.Emp_ID IN (SELECT Emp_id FROM employee) ORDER BY pa.id DESC;

    -implement-

    WHERE E.Emp_ID IN (SELECT Emp_id FROM employee) ORDER BY pa.id DESC;

    Kind regards
    Mike

  • How to use this translate! 1.8

    I installed translate this! 1.8, but no icon appeared in my toolbar of the modules and there is no entry in the Tools menu after you restart Firefox. If I select the menu and right-click, text list not to be translated. Under view > toolbars > customize, there is no icon for the add-on. So, how can I use this add-on? Where is he? I use Firefox 10.

    OK, this is weird. I rebooted again and now it works. Why I had to reboot twice and reopen Firefox yet before translating 1.8 would work is a mystery. Must be the phase of the Moon or something.

  • What is VISA % 3F components how to use this % 3F

    Hi all

    I'm a beginner for labview, so I want to know clearly about the VISA components and how to use it? Please help me learn LabVIEW

    Thank you in advance,

    Check this post. There is also an attached document (pdf), which is the introduction of VISA. After going through it, you can ask questions of the special about VISA.

  • My model have fax modem and if yes how to use this 'thing'!

    my model number is dv7-3079wm. I was told of Wal - Mart.com I could fax from my computer if I had a fax modem. I don't know if my computer has one or not. If this is the case, how I use the program and how do I know if I have analog or digital telephone lines. I would like a step by step process.

    Your laptop has a RJ-11(#5 shown in picture below) port on the right side of the laptop where you can connect the phone cable and use your laptop computer to send FAXES to others.

    Please read the guide and watch the video on how you can set up the fax on your laptop computer at the link below

    http://Windows.Microsoft.com/en-us/Windows7/set-up-your-computer-to-send-and-receive-faxes

Maybe you are looking for

  • FireFox 39 Incompatible with all Cisco devices

    With the last update access to all devices Cisco via FireFox is no longer supported. Now, I get the following errors: The secure connection failedAn error occurred during a connection to [IP]. SSL has received a low ephemeral Diffie-Hellman key in th

  • You can merge pictures libraries

    I stupidly created a library 2nd in pictures and now I want to go back to! Is it possible to merge

  • Timer switch

    Hello I would like to generate a sinusoidal waveform of 2 Assistant DAQ source dry after that the VI is called. The source then used to run a battery of Piezoceramics. How can I activate the source automatically using timer after 2 seconds? Thank you

  • Skype 'problem with sound recorder '.

    After working perfectly for months, when I now try to use Skype I get the above message.  CD works perfectly all the other its OK.  Skype gave me a chapter and verse to uninstall and reinstall Skype without change.  I guess the problem is in the web

  • field calculated as a player is not adding up

    I created a form in Acrobat for reimbursement of costs. One of the fields in the section D calculates the reimbursement of mileage to $.54 a thousand. This formula works fine but don't no subtotal section D until something else is entered in the same