Need of a query:-Urgent

COLUMN_NAME

ID

PK

NULL VALUE?

DATA_TYPE

CALENDAR_CODE

1

N

VARCHAR2 (10 byte)

EXCEPTION_SET_ID

2

N

NUMBER

CALENDAR_DATE

3

N

DATE

LAST_UPDATED_BY

4

N

NUMBER

CREATION_DATE

5

N

DATE

CREATED_BY

6

N

NUMBER

LAST_UPDATE_LOGIN

7

THERE

NUMBER

LAST_UPDATE_DATE

8

N

DATE

SEQ_NUM

9

THERE

NUMBER

NEXT_SEQ_NUM

10

N

NUMBER

PRIOR_SEQ_NUM

11

N

NUMBER

NEXT_DATE

12

N

DATE

PRIOR_DATE

13

N

DATE

REQUEST_ID

14

THERE

NUMBER

PROGRAM_APPLICATION_ID

15

THERE

NUMBER

PROGRAM_ID

16

THERE

NUMBER

PROGRAM_UPDATE_DATE

17

THERE

DATE

SQL query:

Select calendar_date, To_char (calendar_date, 'DY') dayofweek, to_char (calendar_date, 'YYYYMMDD'), calendar_code

of bom.bom_calendar_dates

Where 1 = 1

and calendar_code = 'MI-Cal. '

and to_char (calendar_date, 'YYYY') = to_char(sysdate,'YYYY')

and seq_num is null

calendar_date asc order

My table structure looks like this... and the following query gives me the list of public holidays for this year.

I need a query to check the list of public holidays for next year... ? Can anyone help on this... as soon as possible. ?

Try below:

Select calendar_date, To_char (calendar_date, 'DY') dayofweek, to_char (calendar_date, 'YYYYMMDD'), calendar_code

of bom.bom_calendar_dates

Where 1 = 1

and calendar_code = 'MI-Cal. '

and to_char (calendar_date, 'YYYY') = to_char(sysdate,'YYYY')+ 1

and seq_num is null

calendar_date asc order

Tags: Database

Similar Questions

  • Urgent need for sql query

    Hi all
    Sorry I can't speak English very well
    =======================
    I have a table that contains two columns
    table name: total_sal
    column name: hire_date
    column name: salary

    table syntax

    create table total_sal (hire_date date
    number (6.2)) of salary;
    _________________________________________
    Example of data in table format

    hire_date | salary
    01/01/2011 | 1000
    01/02/2011 | 2000
    01/05/2011 | 500
    01/09/2011 | 400


    I NEED a SQL QUERY to display the table, as in this example

    OF | TO|||||||||||| TOTALSALAY
    01/01/2011 | 01/02/2011 | 3000
    07/05/2011 | 01/09/2011 | 900
    |||||||||||||||||||||||||||||||||| 3900
    /* Formatted on 9/23/2011 10:14:40 AM (QP5 v5.149.1003.31008) */
    WITH t
            AS (SELECT TO_DATE ('1/1/2011', 'mm/dd/yyyy') hire_date, 1000 salary
                  FROM DUAL
                UNION
                SELECT TO_DATE ('2/1/2011', 'mm/dd/yyyy'), 2000 FROM DUAL
                UNION
                SELECT TO_DATE ('5/1/2011', 'mm/dd/yyyy'), 500 FROM DUAL
                UNION
                SELECT TO_DATE ('9/1/2011', 'mm/dd/yyyy'), 400 FROM DUAL)
    SELECT "From", "To", totalsalary
      FROM (SELECT hire_date "From",
                   LEAD (hire_date) OVER (ORDER BY hire_date) "To",
                   salary + LEAD (salary) OVER (ORDER BY hire_date) totalsalary,
                   ROW_NUMBER () OVER (ORDER BY hire_date) rn
              FROM t)
     WHERE MOD (rn, 2) = 1
    UNION ALL
    SELECT NULL, NULL, SUM (salary) FROM t
    
    From     To     TOTALSALARY
    1/1/2011     2/1/2011     3000
    5/1/2011     9/1/2011     900
              3900
    
  • Need help for query flat_file type clobdata oracle table data.

    Hi Sir,

    I need help to query oracle table flat file data having given clob type.
    Oracle Version:
    
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    
    
    Source table
    
      CREATE TABLE order_details 
       (     QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         CHAR_DATA CLOB, 
         OPTIMISTIC_LOCK_KEY NUMBER(20,0)
       ) 
    COLUMN FOR CHAR_DATA FLAT_FILE
    EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT
    EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT
    EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT
    EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT
    EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT
    EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT
    EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT
    EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT
    EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT
    EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT
    EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
    EXPECTED RESULTS:
    AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY             SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY        
    EU          6067AT       AT10                 000000402004       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             
    EU          6068AT       AT11                 000000402005       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             

    Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
    Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something as

    select table_row,
           level clob_row,
           regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line
      from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row,
                   char_data
              from order_details
           )
     connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null
            and prior char_data = char_data
            and prior table_row = table_row
            and prior sys_guid() is not null
    

    to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.

    Concerning

    Etbin

    Edited by: Etbin on 3.2.2013 09:01

    .. .but I m connected to do things according to the instructions, I can't do something.

    Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
    rp0428 post - something to remember.

  • Need to SQL query to filter records by limited rows and certain condition

    Hello guru (s).

    I need a SQL query for help.
    For an example table t1 as below, I want to find the maximum of 5 larger, but there should be no more than 2 name of the same position. The "BOLD" is the response of desire.

    Name Position size
    N1 P1 5
    N2 P2 50
    N3 P3 500
    N4 P1 6
    N5 P2 60
    N6 P3 600
    N7 P1 7
    N8 P2 70
    N9 P3 700

    Thank you.

    not tested!

    select name,position,size,
      from (select name,position,size,
                   row_number() over (order by size desc) a_count
              from (select name,position,size,
                           row_number() over (partition by position order by size desc) a_count
                      from your_table
                   )
             where a_count <= 2
           )
     where a_count <= 5
    

    Concerning

    Etbin

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Need help with query

    Have the rank as below,

    name of the sum

    100 A1

    -A2 200

    A3 300

    50 A1

    -A2 700

    A3 80

    10 A1

    -A2 90

    30 A3

    Need to query to extract the output like this:

    B1                     B2

    A1 + a3 (Sum) A2 (sum)

    Please help me out of this...

    Hello

    It is difficult to understand what you want... A guess based on many assumptions:

    -B1 and B2 are column headers,
    -"A1 + A3" and "A2" in the 'exit' is simply to indicate that you want the sum of the amounts for the first names.

    -Some of the AI have all their amounts > = 0, others have their amounts<=>
    -You want to make the sum of all positive numbers in the first column and all the negatives in the second column

    SELECT SUM (GREATEST (0, t.amount)) b1

    , B2 SUM (LESS (0, t.amount))

    MYTABLE t

    ;

    (I think there is only a bit of luck it's really what you want, but provide a full test case and the output that you really want and why not, try to explain / explicit rules, then we can give better help)

    Best regards

    Bruno Vroman.

  • need of a query

    I have a requirement...

    I have to delete the data in a table that is not present in another table

    I wrote a query like this

    remove a and b where not EXISTS (select account_id of aaa where a.account_id = b.acc);

    I need a query without using the EXISTS operator...

    No, you can not join, but you actually do what needs to be done using a correlated subquery.

    What is the problem you're trying to solve?  You can reach both what you want, what is the problem with the help of these EXISTS and IN?

  • Need to extract query text in each row tags

    I need to display a list of tags used in particular the text for each line. After sample data can give clear you the idea.

    DB version:

    ========

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    Sample data:

    ==========

    WITH txt_data AS)

    SELECT the 1 id, txt "your price #toy_name # is #price_amt #.» FROM DUAL

    UNION ALL

    SELECT id 2, "it's product tag #pdt_tag #." It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' txt FROM DUAL

    UNION ALL

    SELECT 3 id, "Hi Mr. #clt_name #." txt FROM DUAL

    )

    SELECT * FROM txt_data;

    Power required:

    ============

    ID TAGS
    1#toy_name #, #price_amt #.
    2#pdt_tag #, #clt_tag #, #adv_tag #.
    3#clt_name #.

    To implement this I used the technique of factoring of the recursive subquery for a static data (row). Seen the query below.

    WITH tag_list (ip_str, case, tag) as)

    SELECT ' this is product #pdt_tag tag #. It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' AS ip_str, 0 accident AS, null AS tag FROM DUAL

    UNION ALL

    SELECT ip_str, here + 1, REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) OF tag_list WHERE REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) IS NOT NULL

    ), SELECT WMSYS. WM_CONCAT (tag) OF tag_list WHERE case > 0;

    But when I use this technique for the data in the table, it gives me the error. Given below.

    WITH txt_data AS)

    SELECT the 1 id, txt "your price #toy_name # is #price_amt #.» FROM DUAL

    UNION ALL

    SELECT id 2, "it's product tag #pdt_tag #." It is a client #clt_tag tag # and finally this notice tag #adv_tag #. ' txt FROM DUAL

    UNION ALL

    SELECT 3 id, "Hi Mr. #clt_name #." txt FROM DUAL

    )

    SELECT t.id,

    (WITH tag_list (ip_str, case, tag) as ())

    SELECT t.TXT AS ip_str, 0 accident AS, null AS tag FROM DUAL

    UNION ALL

    SELECT ip_str, here + 1, REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) OF tag_list WHERE REGEXP_SUBSTR (ip_str, ' (#. *?)) (#)', 1, case + 1) IS NOT NULL

    ), SELECT WMSYS. WM_CONCAT (tag) OF tag_list WHERE case > 0) as tags

    OF txt_data t.

    ORA-00904: "T". "" TXT ": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 50: 17

    Issues related to the:

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

    1. help reach my goal (with your own logic, whatever my technique)

    2. What is the problem with my technique above? Cannot use us WITH the clause in the selection list?

    Thanks in advance

    Personally I would rewrite the expression of regexp as ' #[^ #] * #'

    In addition, we can get rid of the place where the main expression

    with tag_list (ip_str, case, tag) as)

    SELECT TXT AS ip_str, 1 match AS

    REGEXP_SUBSTR(txt, '#[^#]*#', 1, 1) AS tag

    of txt_data

    UNION ALL

    SELECT ip_str, here + 1

    , REGEXP_SUBSTR (ip_str, ' #[^ #] * #', 1, case + 1)

    OF tag_list

    WHERE REGEXP_SUBSTR(ip_str, '#[^#]*#', 1, occurrence + 1) IS NOT NULL

    )

    SELECT

    ip_str

    , listagg (tag, ',') within the Group (by instance) s

    OF tag_list

    Ip_str group

    Finally, you can save a regexp_substr

    with tag_list (ip_str, case, tag) as)

    SELECT TXT AS ip_str, 1 match AS

    REGEXP_SUBSTR(txt, '#[^#]*#', 1, 1) AS tag

    of txt_data

    UNION ALL

    SELECT ip_str, here + 1

    , REGEXP_SUBSTR (ip_str, ' #[^ #] * #', 1, case + 1)

    OF tag_list

    )

    cycle tag cyl set default 1 0

    SELECT

    ip_str

    , listagg (tag, ',') within the Group (by instance) s

    OF tag_list

    Ip_str group

  • need help hard query

    Hello

    I'm trying to find out who is the manager who have more number of carried forward under him of emp table

    can you please help me how to find... I searched the forum and I tried some queries but does not work...

    Thank you

    ASP.

    Hello

    You need to display the results of the sample such that people who want to help you can recreate the problem and test their ideas.  Do you think that people can run what you posted?  You must post CREATE TABLE and INSERT statements or equivalent SB.

    Once more, if you use a commonly available table, for example scott.emp, just say.

    Explain how you get these results.  For example, "when I say 'Manager', I mean the employee identified in the mgr column; It does not matter if job = 'MANAGER' or not.  In this issue, I'm only interested in direct subordinates.  For example, the KING (empno = 7839) is Manager, directly or indirectly, the other 13 lines in the table, but only 3 of these lines have mgr = 7839.  There are 5 lines having mgr = 7698 (for BLAKE), so I want BLAKE rather than KING. »

    Here's a way to do it:

    WITH got_rnk AS

    (

    SELECT m.empno, m.ename, m.job - or other columns of your choice

    EARL of (e.mgr) AS reportee_count

    , EVALUATE () OVER (ORDER OF COUNT (*) / / DESC) AS rnk

    FROM scott.emp m

    LEFT OUTER JOIN scott.emp e ON e.mgr = m.empno

    GROUP OF m.empno, m.ename, m.job

    )

    SELECT reportee_count, empno, ename

    OF got_rnk

    WHERE rnk = 1

    ;

    Exit from scott.emp (in the case that is different from what you have posted);

    EMPNO, ENAME, JOB REPORTEE_COUNT

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

    7698 BLAKE MANAGER 5

    If there be a tie for the line with the majority of direct reports, the above query will display all the contenders.

  • I need help for query AVG

    I need help with a simple query in an ORACLE database. I tried a lot of things that I found on the internet, but none of them worked for me.

    The following query retrieves four lines:

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM < 5

    ORDER BY sampled_date DESC;

    I would like to calculate a moving average of the last four values with the date of the sample of the last line.

    For example, I have this result for the query above:

    Value1 value2 value3

    01/04/14-16:00 1 0

    01/04/14 15:00 2 0

    01/04/14 14:00 3 0

    01/04/14 13:00 4 0

    I want to extract the below my average/query calculation result:

    Value1 value2 value3

    01/04/14-16:00 2.5 0

    Can you help me create a request to that effect?

    Thank you

    Maybe it's

    Select max (VALUE1) VALUE1, VALUE2 avg (VALUE2), avg (VALUE3) value3

    Of

    (

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM<>

    )

  • Need help with query Cumulative difference

    Hi all

    I need help with a query and my requirement is as below

    {code}

    ROWNOORDERSVALUE

    110900
    211700
    312500
    413400

    {/ code}

    I have need to query which will display the cumulative difference for example I value tell 10000 numbers opening

    now I need for each of the lines of cumulative difference

    {code}

    ROWNO ORDERS DIFF

    1 10 10000 - 900 = 9100

    2 11 9100 - 700 = 8400

    3 12 8400 - 500 = 7900

    4 13 7900 - 400 = 7500

    {/ code}

    WITH commands LIKE (10 SELECT order_id, 900 double UNION ALL val
    11. SELECT, 700 FROM dual UNION ALL
    SELECT 12, 500 FROM dual UNION ALL
    Select 13, 400 double)

    SELECT row_number() over (ORDER BY order_id ASC) AS rowno
    order_id
    sum (val) 10000 - OVER (ORDER BY order_id ASC) AS diff
    orders

    /

    HTH

  • Need help for query joining views

    Hi all

    I need to run a query that joins a number of tables with multiple instances of the same view.  For example, a view named MY_VALUES, is an array of key / value resembles the following:

    Application_ID Attirbute_Description value

    1 1 000 basic benefit

    1 multiplier 1 0.5

    1 Multiplier_2 1.2

    1 total profit 1,115

    2 1 025 basic benefit

    2 multiplier 1 0,268

    2 Multiplier_2 1.3

    Total profit 2 1.4500

    Say I want a query that selects basic earnings and a multiplier 1 for Application ID 1, as well as, other information from a table called APPLICATION that has a relationship to display pk - fk. I would do the following:

    Select the application. Name, mv1.value, mv2.value

    from dbo. App APPLICATION, dbo. MY_VALUES mv1, dbo. Mv2 MY_VALUES

    where app.id = mv1.application_id and mv1.attribute_description = "Basic benefits"

    and app.id = mv2.application and mv2.attribute_description = id 'multiplier 1'.

    and app.id = 1

    My actual query is similar to this. However, I have many other attributes of the notice I need to select, which requires that the view be attached to several times. After 16 these joins, the request is fine. After 17, however, the query runs always, never return a result within 45 minutes I have let it run.

    Is there a better way to write such a request or an indicator of optimization that would be useful here?

    Any help is greatly appreciated.

    ....

    For this type of application, it is often best to extract multiple lines in a single request on the view and their pivot in the output.

    For example

    Select the application. Name

    , max (CASE when mv.attribute_description = "Core service" then mv.value any other purpose) BaseBenefit

    , max (CASE when mv.attribute_description = 'Multiplier 1' then mv.value any other purpose) Multiplier1

    , max (CASE when mv.attribute_description = 'Multiplier 2' then mv.value any other purpose) Multiplier2

    , max (CASE when mv.attribute_description = 'Multiplier 3' then mv.value end to another null) Multiplier3

    from dbo. App APPLICATION, dbo. MY_VALUES mv

    where app.id = mv1.application_id

    and mv.attribute_description IN ('benefits of home', 'multiplier 'multiplier 'multiplier 3' 2' 1')

    and app.id = 1

    This runs often much better than several joins to the table for the view or the value of the attribute.

  • Need a SQL query

    Hi friends,

    Can someone me posts sub queries SQL:

    1 need a query to find locked users and name of the table to each scheme.

    2. a query need to know the user using tables in each schema.

    Thank you

    Lazar T

    Hello

    1. What do you mean under the user table and it is locked?

    2 search for locked objects

    SELECT a.sid,a.serial#, a.username,c.os_user_name,a.terminal,
    b.object_id,substr(b.object_name,1,40) object_name,sysdate
    from v$session a, dba_objects b, v$locked_object c
    where a.sid = c.session_id
    and b.object_id = c.object_id

    ----

    Ramin Hashimzde

  • Need a sql query to get several dates in rows

    Hi all

    I need a query to get the dates of the last 7 days and each dates must be in a line...

    but select sysdate double... gives a line...

    Output of expexcted

    Dates:

    October 1, 2013

    30 sep-2013

    29 sep-2013

    28 sep-2013

    27 sep-2013

    26 sep-2013

    Try:

    SQL > SELECT sysdate-7 + LEVEL FROM DUAL

    2. CONNECT BY LEVEL<=>

    3 * ORDER BY 1 DESC

    SQL > /.

    SYSDATE-LEVEL 7 +.

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

    October 1, 2013 13:04:52

    30 - Sep - 2013 13:04:52

    29 - Sep - 2013 13:04:52

    28 - Sep - 2013 13:04:52

    27 - Sep - 2013 13:04:52

    26 - Sep - 2013 13:04:52

    25 - Sep - 2013 13:04:52

    7 selected lines.

  • Need of below query output

    WITH rcv_transactions 
         AS (SELECT 1001      TRANSACTIONS_ID, 
                    -1        PARENT_TRANSACTION_ID, 
                    'RECEIVE' TRANSACTION_TYPE, 
                    NULL      LPN_ID, 
                    'LPN01'   TRANSFER_LPN_ID 
             FROM   dual 
             UNION ALL 
             SELECT 1002, 
                    1001, 
                    'DELIVER', 
                    'LPN01', 
                    'LPN01' 
             FROM   dual 
             UNION ALL 
             SELECT 1003, 
                    -1, 
                    'RECEIVE', 
                    NULL, 
                    'LPN01' 
             FROM   dual) 
    SELECT * 
    FROM   rcv_transactions; 
    
    My output for the above query is 
    
    transactions_id   parent_transaction_id   transaction_type     lpn_id     transfer_lpn_id
    ---------------------------------------------------------------------------
    1001                        -1                          receive                                 lpn01
    1002                    1001                           deliver                  lpn01      lpn01
    1003                         -1                         receive                                lpn01
    
    
    I want the output as below:
     TRANSACTIONS_ID,   PARENT_TRANSACTION_ID,  TRANSACTION_TYPE,     LPN_ID,     TRANSFER_LPN_ID, 
    1003                                    -1                                   RECEIVE                                   LPN01
    
    i.e., I want the transactions id which are only 'receive' and not 'deliver' for the particular transfer_lpn_id
    
    in the above scenario 1001 is received and delivered in 1002. 
    
    But 1003 is only received. so  I need the output of 1003
    WITH rcv_transactions AS (SELECT 1001 TRANSACTIONS_ID,
                                     -1 PARENT_TRANSACTION_ID,
                                     'RECEIVE' TRANSACTION_TYPE,
                                     NULL LPN_ID,
                                     'LPN01' TRANSFER_LPN_ID
                                FROM DUAL
                              UNION ALL
                              SELECT 1002,
                                     1001,
                                     'DELIVER',
                                     'LPN01',
                                     'LPN01'
                                FROM DUAL
                              UNION ALL
                              SELECT 1003,
                                     -1,
                                     'RECEIVE',
                                     NULL,
                                     'LPN01'
                                FROM DUAL)
    SELECT *
      FROM rcv_transactions rcv_out
     WHERE rcv_out.transaction_type = 'RECEIVE'
           AND NOT EXISTS
                  (SELECT 1
                     FROM rcv_transactions
                    WHERE parent_transaction_id = rcv_out.TRANSACTIONS_ID)
    

Maybe you are looking for

  • Portege M400 - batteries do not charge

    I recently bought a Portege M400 via a website selling popular auction, and all right, except that the battery won't charge. The LED does not illuminate and the machine is therefore not portable.I bought a spare battery, but that does not work either

  • Where is the folder 'My Photo Stream' located locally on a Mac?

    Hi all I try to access the folder 'My Photo Stream' on an MBA with El Capitan 10.11.3 with the Finder, but can't seem to find anywhere. To be clear, I'm not trying to find my iCloud photo file, unless they are the same thing. My guess is that since t

  • OfficeJet PageWide Pro 477dw: Officejet PageWide Pro 477dw D3Q20B drivers for Mac?

    Where can I download HP PageWide Pro 477dw D3Q20B drivers for Mac? 'HP Easy Start' is no solution.I need to install on 30 laptops. I can't click on Gui and wait for downloads on 30 machines. Driver is not included in El Capitan 10.11.6 updating. Empt

  • Help burning CD

    I'm trying to burn an audio CD. I ripped the songs and medicines to the list pane. When I click on burn, nothing happens. In the past, it has bold "start burn" and after clicking on it would start the burning process. What I am doing wrong this time?

  • GroupDataModel how to search for an item and row

    Hi all! I have a problem with GroupDataModel. I create and fill out the template as below: m_model = new GroupDataModel(QStringList() getId()); entry["displayName"] = contact->getDisplayName(); entry["icon"] = contact->getSmallPhoto(); m_model->inser