Necessary emergency with a request: fill date of prior art on the column name

Hello

Can you please help me with the query. I would be grateful for your time and your help.

I have the query and the following output. Basically, the query selects a date, a table and counties received documents based on the current date, day-1, - 2 days-, 3 days-4 days-5 days and especially 5 days. It's the query I wrote. Now the requirement has slightly changed and described below.

Current query:

SELECT SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 0 PUIS 1 AUTRE 0 FIN) Zéro ,

SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 1 PUIS 1 AUTRE 0 FIN)   One ,

SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 2 PUIS 1 AUTRE 0 FIN) Two ,

SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 3 ALORS 1 SINON 0 FIN) Trois ,

SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 4 PUIS 1 AUTRE 0 FIN) Quatre ,

SUM (BOX WHEN TRUNC (SYSDATE) TRUNC (File_Date) = 5 THEN 1 ELSE 0 END) Five ,

SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() > 5 PUIS 1 AUTRE 0 FIN) OverFive ,

COUNTY (*) Total

DE DOCUMENT_TABLE

OUTPUT:

Zero

One

Two

Three

Four

Five

More than five

Total

3

6

3

6

10

50

100

178

Now the desired output:

The column name must be the date, for example the column name, we're Sysdate, two column name is Sysdate-1 day and the result would look like:

OUTPUT:

17/12/2014

16/12/2014

15/12/2014

14/12/2014

13/12/2014

12/12/2014

More than five

Total

3

6

3

6

10

50

100

178

Hi, just try below as you say it's urgent

Select sysdate, sysdate-1, sysdate-2, sysdate-3,-4, etc of daul sysdate

Union

your query

(you must ensure for the same type of data)

are you using oracle report or just in the sql query. If the reports, then you can manage very easily with the introduction of a formula column.

Tags: Database

Similar Questions

  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

  • Display the name of the tag as the column name and the value in the tag as a row of data from the input string.

    Hi Forum members,

    I am looking for a query display the name of the tag as the column name and the value in the tag as a row of data.

    I have to print the values within the tag to a file by choosing the value of the flags. the sequence of the tags will vary each time, as the tag name will change dynamically.

    So here is the example of input data and the expected output. The string in the text column must be separated as the column names and values.

    Input data
    Select 1 as seqno,' < > 0210A 50 4f < / 4f > < 5f20 > TEST CARD 16 < / 5f20 > < 5f2a > < / 5f2a > < 82 > 1 c 00 < / 82 > ' double text


    Output:

    Seqno 4f 5f20 5f2a 82
    0210A 50 16 1 00 TEST CARD 1

    Please help me by providing your entries on this.

    We use the version of Oracle 11.2.

    Note: This is not the XML string

    Thank you

    Shree

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    )

    Select d.seqno, x.*

    d the data,

    XMLTable ('/ root')

    by the way xmltransform (xmltype ('': replace (replace (text,'<><>'),)))

    XmlType (q'~http://www.w3.org/1999/XSL/Transform "version ="1.0"> ")

                                                     

                                                       

                                                         

                                                       

                                                     

                                                     

                                                       

                                                         

                                                       

                                                     

    ~'

    )

    )

    path of columns '4f' varchar2 (10) "tag4f."

    path of "5f20' varchar2 (30)"tag5f20. "

    path of '5f2a' varchar2 (10) "tag5f2a."

    path of varchar2 (10) "82" "tag82.

    ) x


    SEQNO 4f 5f20 5f2a 82
    1 0210A 50 16 TEST CARD - 1 00
    2 0210A 50 16 TEST CARD - 1 00
    3 0210A 50 16 TEST CARD - 1 00
    4 0210A 50 16 TEST CARD - 1 00

    with

    data in the form of

    (select 1 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2a><82>00 1' text of all the double union)

    Select 2 as seqno,'XYZ<4F>0210 A 50<5f20>TEST CARD 16<5f2a><82>00 1' text of all the double union

    Select 3 as seqno,'<4f>0210 A 50<5f20>TEST CARD 16<5F2A><82>1 00XYZ ' text of all the double union

    Select option 4 as seqno,'<4F>0210 A 50<5F20>TEST CARD 16<5f2A><82>1 00XYZ' double text

    ),

    Chopper (seqno, Key, value, String) as

    (select seqno,

    regexp_substr (text,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (Text,'>(.*?))

    regexp_substr (text,'<.+?>. *? ) (.*) $', 1, 1, null, 1). » <>'

    from the data

    Union of all the

    Select seqno,

    regexp_substr (String,'<(.+?)>', 1, 1, null, 1),

    regexp_substr (String,'>(.*?))

    regexp_substr (String,'<.+?>. *? ) (.*) $', 1, 1, null, 1)

    Chopper

    where regexp_substr (string,'<(.*?)>', 1, 1, null, 1) is not null

    )

    Select '4f', seqno, '5f2a', '82', '5f20.

    of (seqno, lower (key) select key, value)

    Chopper

    )

    Pivot (max (value) for key in ('4f' as '4f', '5f20' as '5f20', '5f2a' as '5f2a', "82" as "82"))

    Concerning

    Etbin

  • Dates are not appearing in the column start and Finsh of MS Project 2010. They become W31/4, W31/5, etc. Instead of 7/31/20113. How can I fix it?

    Dates are not appearing in the column start and Finsh of MS Project 2010. They appear rather like W31/4, W31/5, etc. When it should be like this: 7/31/20113. How can I fix it? Note: Dates listed do appear correctly.

    Hello Charlie,.

    You are welcome. It is what we are trying to do... help people! Thanks for letting me know that the problem is solved. Don't forget to mark it as your response so that we can spread the knowledge more far.

    Kind regards

    BearPup

  • VM with disks of different data warehouses. Snapshots on the same data store?

    Hello

    We have several virtual machines with disks on different data stores for reasons RAID.

    Last night, we found that the snapshots of all disks are left on the data store main vmx and not on each datastore disk.

    How will we change this as our OS data warehouses are small and run out of space when running shadow copies?

    Thank you

    Frogbeef

    You can change the location of snapshots, but they will all go to this place - as far as I know, you cannot change the location of each disk.

    The KB http://kb.vmware.com/kb/1002929 explains how to do this.

    Kind regards

    Marcelo Soares

    VMWare Certified Professional 310/410

    Master virtualization technology

    Globant Argentina

    Review the allocation of points for "useful" or "right" answers.

  • Problem with form to fill out (landscape format), text of the evil orientation entry

    Hello

    Problem on Mac, form with fields to fill out. Fill in the text in the form field ok, after enter the text appears in the wrong (not a problem in windows) orientation. Any ideas?

    Thank you very much

    Beat

    I checked on a MacPro running Acrobat Pro 9.1.2 and all is well in shape. Text is common sense and tab fields in the correct order.

  • DATE format - when you set the column in the table

    Hi friends,

    I came across a piece of code that applied a TO_DATE() function on a column of type date.

    I have two tables t1 and t2 and they have columns col1 and col2 respectively of type DATE
    t1
    col1 DATE
    
    t2
    col2 DATE
    There is also a variable var1 and is defined as follows:
    var1 DATE;
    now, I like conditions below in the code:
    AND to_date(t1.col1,'dd/mm/yyyy') = to_date(t2.col2,'dd/mm/yyyy')
    AND to_date(t1.col1,'dd/mm/yyyy') = to_date(var1,'dd/mm/yyyy')
    This code has failed on the Production with an error: ORA-01861 literal does not match the format string

    I changed the code to remove TO_DATE() and it worked fine. Dev said that they used this function for that if the two columns or variable is in the date format of diff.,... they can be brought into harmony.
    for example if col1 is dd/mm/yyyy and col2 is dd/mm/yyyy, then there will be a problem.

    My doubt is... in a given environment if we create a table and define a DATE type column, or define a variable of type DATE, their format may be different at any time? I think that no.?

    In this scenario, the date format can be different?

    Thank you

    your thoughts are correct. A date is a date, the question of how it is shown on the interface is a different matter.

  • With the help of inplace column number of the column name in the SQL Select statement

    Is it possible to execute instructions select sql with the number of columns in
    place names of columns?

    Run SQL
    select AddressId,Name,City from Address
    Is it possible
    select 1,2,5 from Address
    Thanks in advance

    You can extract the names of the columns for user_tab_columns
    with

    SELECT Column_name
    FROM user_tab_columns
    where table_name = 'MY_TABLE'
    and Column_id in (1,2,5)
    

    Use dynamic SQL and then the result to get the values.

    But as others already mentioned, this wil it be given incorrect if your table is changed.

  • Get the column names with cursor or an alternative

    Hi guys,.

    What I currently have is an email with an attachment from PL/SQL. I need to display the query results in .txt attachment. What I've done now is to use a slider but it shows only the results I want column names & ideally the message "14 rows returned. How could I put this in a VARCHAR2?

    Mike

    Add a value to each sub selection order by...

    for example

    SQL> set heading off
    SQL> ed
    Wrote file afiedt.buf
    
      1  select colA, colB, colC
      2  from (
      3        select 1 as ord, cast('TABLE_NAME' as char(30)) colA,cast('GRANTEE' as char(30)) colB,cast('PRIVILEGE' as char(30)) colC from dual
      4        union all
      5        SELECT 2, rpad('-',30, '--') colA, rpad('-',30, '--') colB, rpad('-',30, '--') colC from dual
      6        union all
      7        select 3, cast(table_name as char(30)) colA,cast(grantee as char(30)) colB,cast(privilege as char(30)) colC from user_tab_privs where table_name like 'EMP'
      8       )
      9* order by ord, colA
    SQL> /
    
    TABLE_NAME                     GRANTEE                        PRIVILEGE
    ------------------------------ ------------------------------ ------------------------------
    EMP                            SCOTT                          SELECT
    
    SQL>
    
  • Hi, I just upgraded from 6.1 to 6.4 LR LR. When importing new files LR6.4 cannot rename my files with a specific date format (import uses only the original name).

    Hello

    No problem with the LR 6.1, but now (LR6.4), it seems impossible to rename my files with a specific format (yyyy-dd-hhmmss and a suffix) importing memory cards. LR imports only files with names of origin. And I have a lot of files to rename...

    I hope that someone knows what's going on.

    Jean

    Jean,

    We found a similar question which is being implemented. If you shoot images at once in the first and jpg format and then import them using the option of renaming, the question is in place.

    Could you please check if you use the option "make a second copy? If so, please it deselect. It should solve the problem.

    The issue is addressed in Lightroom.

    Thank you

    Sunil

  • Display of the results of the query with the column names unknown

    I use this code to grab the headers of columns in a select * statement. (I never know what table is queried out of 12 000 or more.) I want to make a loop on the column headers, then the query results in a web page table.

    < cfoutput >
    < cfset colHeaderNames = ArrayToList (recordset1.getColumnList ()) / >
    #colHeaderNames #.
    < / cfoutput >

    Is there a similar method or suggestions for the release of the results of the query - now that I know the column headings?

    If I understand correctly, you can do something like the code below.

  • The column names in the data grid redraw error

    When resizing a datagrid control (using States and transitions and setting the visible property of a couple of true columns) column headers grow too large and spend in scrolling vertical bar, when I click on the datagrid control redraws correctly.

    Any idea what I can do to fix this?

    Thanks David

    I found the solution. You must define more precisely the width of each column in the initial state, not only the minWidth.

  • With the help of trigger to copy lines without specifying the column names

    Hello

    I have a large table:
    Time V0 V1 S1 S0... V800 S800

    I make a copy of this table.

    Then, I want to create a trigger that inserts all rows in the copy whenever they are inserted in the original:
    create or replace trigger gila_dem2_trig
    before inserting
    on gila_dem2_1_1m
    REFERRING AGAIN AS NINE OLD AND OLD
    FOR EACH LINE
    Start
    insert into gila_dem2_1_1m_copy (V0 of time... S800) values (: new.) New time: V0.., new: S800)
    end;

    I want to do this without having to explicitly name the columns. Something like: nouveaux.* would be nice
    but does not work.
    Is there a way to do this?

    Concerning
    Tomas

    While you can write dynamic SQL statements in triggers it won't help.

    You will not be able to dynamically reference the: NEW values.

    Your only choice is to specify all columns

  • date is not fitting on the page of report

    Hi friends,

    I created a form page with the report, in which insertion I made in the forms should take into account in the report

    In my form, what are the corresponding fields

    Requested by:
    start date:
    status:
    priority:

    My requirement in the form is when I logged on the form for an entry page, the field start date should automatically have the current sysdate and I need to fill the other fields to make an entry in report...

    I also brought the corresponding sysdate in my form date field beginning when I opened the form, but the problem for me, it's that the only departure date field is not get inserted in my table, except this field than all the other field is get inserted...

    How I did the sysdate appear in means of start date field,

    Under the source of the field point date beginning, I made the following changes

    Source: replace an existing value in a session state
    source type: static assignment (equal to the source value)
    source of value or an expression: I gave the following sql query as

    Select sysdate double;

    shortly after this change, when I login in the application, to put an entry form

    sysdate is automatically displayed in the start date field, but is not fit in my report, shortly after I give create button on my form page...

    For wat to leave is not inserting... If any other string available for the passage of sysdate in apex

    If he can afford so... share with me friends...

    Thank you
    Harry...

    Published by: implications on November 20, 2010 03:18

    Hi Harry,.

    First of all, make sure that your dateitem has a 'Format mask' - for example, DD/MM/YYYY

    Then, need to be addressed "Source":

    Source: replacement always, value that exists in session state
    Source type: column database
    The source value or expression: (enter the name of the column - for example, HIREDATE)

    Then, in the 'Default' section, enter the following:

    Default value: TO_CHAR (SYSDATE, ' DD/MM/YYYY "")
    The default value type: PL/SQL Expression

    (Make sure that the format of date in TO_CHAR() function matches the format of date picker.

    For a value to record on the disc, the settings of the Source would be the above in general - words, you must specify that it is a database column and enter the column name of database as a Source value. Otherwise, Apex will not be able to save the data in this field.

    Thus, you must provide another way to enter during the date - and it is done by using the default settings. As long as the field is NULL, the default will apply. Once the field has a date, the default value is no longer used.

    Andy

  • How to load data from matrix report in the base using ODI table data

    Hello

    How to load matrix report data in the base table data using oracle Data Integrator?

    Description of the requirement:

    This is the data from matrix report:
    JOB                       DEPT10                DEPT20  
    ___________________________ _____________
    ANALYST                                           6000
    CLERK                   1300                     1900 
    Need to convert it to the format below:
    JOB                             Dept                        Salary
    _____________________________________________
    ANALYST                  DEPT10      
    ANALYST                  DEPT20                     6000
    CLERK                       DEPT10                    1300
    CLERK                       DEPT20                    1900
        
    Thank you for your help in advance. Let me know if any other explanation is needed.

    Your list seems to be a bit restrictive, you can do much more with the procedures of ODI.

    If you create the new procedure and add a step. In the 'source' tab command you define technology and pattern according to your source database. Use the unpivot operator as described in the link, please, instead of using "SELECT *' use the column names and aliases for example:"

    SELECT workstation,
    deptsal as deptsal,
    saldesc as saledesc
    OF pivoted_data
    UNPIVOT)
    deptsal-<-->
    FOR saldesc-<-->
    IN (d10_sal, d20_sal, d30_sal, d40_sal).<-->
    )

    Then in your tab 'command on target' defined technology and drawing on your target db, then put your INSERT statement for example:

    INSERT INTO job_sales
    (employment,
    deptsal,
    saledesc
    )
    VALUES
    (
    : job,.
    : deptsal,.
    : saledesc
    )

    That's why you use bind variables from source to load data into the target.

    Obviously if the source and target table is in the same database, you can have it all in a single statement to the "command on target' as

    INSERT INTO job_sales
    (employment,
    deptsal,
    saledesc
    )
    SELECT workstation,
    deptsal as deptsal,
    saldesc as saledesc
    OF pivoted_data
    UNPIVOT)
    deptsal-<-->
    FOR saldesc-<-->
    IN (d10_sal, d20_sal, d30_sal, d40_sal).<-->
    )

    also assign the log count "Insert" on the tab corresponding to your INSERT statement, so that you know how many rows you insert into the table.

    I hope this helps.

    BUT remember that this feature is out in Oracle 11 g.

Maybe you are looking for

  • HP product registration pop-up ads (how can I get rid of him!)

    Hi all Can someone tell me how to get rid of the pop up asking me to register my product. All the stuff of HP is registered (out of warranty) but every day, he returned to my screen, even if I clicked on "Don't ask me again" at every opportunity. I a

  • Replacing the screen to Equium A200-1V0

    Hi, my screen was broken recently. I'm looking to replace it to keep it as a spare laptop. I bought a new laptop because I was going to throw it away.Can someone give me an idea of how I should go do that, cost of the part, where to buy etc. Thank yo

  • How to delete songs in Windows Media Player 11 duplicate?

    How to delete songs in Windows Media Player 11 duplicate

  • Loop of starting service pack

    My laptop won't boot no its stuck in a boot loop that gives the message "service pack do not have. Reverting changes do not turn off your computer"I tried to login to safe mood without result, y at - it another way to start the computer and fix this?

  • How to organize import it file text for point retail load line in HFM by FDM?

    At the moment, it's a *.csv file in this format:Year; Period of ; View ; Scenario ; Entity; PEAK; Account ; Custom1; Custom2; Custom3; Custom4; Amount of ; Value ; LineItemDetails; DescriptionFor example, now, I like the content of the file:2012; Qua