Between the SQL Dates

Hello

Can someone help, I need to generate a pivot table to aid between two dates and a Department. I am trying to achieve the following output:

JAN-04 Feb-05 MAR-04 Apr-04 MAY-04 June-04 Jul-04 August-04 SEVEN-04 OCT - 04 etc.
1 1 1 1 1 DEPT
FC
1 1 1 1 1 IF


The SQL code is displayed as below:

"PERSON_ID" "EFFECTIVE_START_DATE" "EFFECTIVE_END_DATE" "DEPT".
1182 12 JANUARY 04 CF 7 MAY 04
1182 17 JUNE 04 31 DECEMBER 12 IF

Can someone help with the realization above PivotTable based on SQL results above

Thank you

Tags: Database

Similar Questions

  • Please explain the difference between the sql data

    Please explain the difference of next sql

    Select emp. ID, Dept. DeptName from Employee emp
    Join (select DeptId, DeptName Department where deptId = 2) dept on emp.deptId = dept.deptId


    Select emp. ID, Dept. DeptName
    employee emp
    inner join Department dept
    on emp. DeptId = Dept. DeptId
    where Dept. DeptId = 2

    two of them provide the same results, but what is the good? Is there a difference... Does this affect performance

    What is the best way of writing

    Thank you

    Published by: user8708731 on August 30, 2011 11:02
    published the first query to select only Deptname

    Published by: user8708731 on August 30, 2011 11:12
    select emp.Id,
           dept.DeptName
      from Employee emp
           join
           (select DeptName, DeptId
              from Department
             where deptId = 2
           ) dept
           on emp.deptId = dept.deptId
    
    all Employee rows are joined to filtered Department rows (a single row or no rows)
    matching deptIds are retained and make their way to the result
    
    select emp.Id,
           dept.DeptName
      from Employee emp
           inner join
           Department dept
           on emp.DeptId = dept.DeptId
     where dept.DeptId = 2
    
    all Employee rows are joined to all Department rows matching deptIds are retained and
    filtered dept.deptIds make their way to the result
    

    Concerning

    Etbin

  • How to count the number of Sundays between the two dates

    Hello

    I want the number of Sundays between the two dates

    example of

    number of number of Sundays between 4 January 2013 ' and April 30, 2013 "in a select query, I have to include this as a sub query in my select statement.

    nordine B wrote:
    Hi Frank,.
    Have 1 doubt...

    In many countries the week could me "Monday". How the application handles it?
    Or did I get something wrong?

    Help, please!

    For ' IW'(ISO week) early in the day is always Monday...

    It's so simple - calculate the weeks between two dates based on Monday... This is the number of Sundays...

    NEXT_DAY is another option...

    SQL> with dd as
      2  (
      3      select TO_DATE('01-04-2013','dd-mm-yyyy') fdt, TO_DATE('30-04-2013','dd-mm-yyyy') ldt from dual
      4  )
      5  SELECT       fdt,ldt,
      6            (next_day(ldt,'sunday')-next_day(fdt-1,'sunday'))/7 sdays
      7  FROM         dd;
    
    FDT       LDT            SDAYS
    --------- --------- ----------
    01-APR-13 30-APR-13          4
    

    Published by: JAC on May 2, 2013 12:20

  • Differences in time between the start date and end Date

    I have a requirement to get the difference between the two dates, I am on the syntax below to fill, but it does not work. The syntax is the following:
    TimestampDiff (SQL_TSI_MONTH, "[< dStart_Date_ITAG >]", '[< dEnd_Date_ITAG >]'). Could you please help me on this. Thanks in advance

    Olivier

    Hello Roytson,

    I want to enjoy the sytem itself, I mean there are 2 custom fields start date and enddate, my function should take system only do not enter manually.
    could you please develop this thing.

  • How to filter dates between the current date and the number of dates past

    Hello

    On the answers, how can I do to return a report that contains data between the current dates and 31 days in the past?

    Users want to connect display the report and the report should show only data 31 days to the date of the day... How would I be able to set it up on the answers that since I have not access to RPD?

    Please let me know

    Thank you

    use the date filter between current_date and timestampadd (sql_tsi_day, -31, current_date)

    fixed

  • Generate the Sql Data model ER diagram

    Hello

    I want to use the Oracle Sql Developer Data Modeler to generate ER diagram for my schema. There are a lot of tables in this schema, so I would like to exclusively identify the tables that should be selected to generate my ER diagram.

    Basically, I want these table that are related to other tables here. The reason being, if I select all the tables in the schema, and then I went to these tables in the ER diagram which have nothing to do with other tables.

    Please can anyone suggest write queries that produce this data dictionary?

    Thank you.

    select uc1.constraint_name,
           uc1.table_name,
           uc1.constraint_type,
           uc2.constraint_name,
           uc2.table_name,
           uc2.constraint_type
    from   user_constraints uc1,
           user_constraints uc2
    where  uc1.constraint_type='R'
           and uc1.r_constraint_name=uc2.constraint_name
    

    This gives you the relationship between the primary and foreign key

  • How to remove empty lines of chain between the relevant data?

    I have problems with the removal of empty lines of final my data output string.  I know this is simple to do, but I'm stuck in the same train of thought.  The file is a converted hex file that is written in a series of recordings.  Convert lines it is result in fa all that data should be deleted and the number of records adjusted accordingly.  I have the code to take the file, convert, delete all of the records with F and adjust the number of files, but I'm left with a gap in my file no matter my approach I can't remove the empty spaces regularly.  I have attached the file with spaces and the goal is to remove the spaces between the blocks of code, and spaces is not always in the same direction.  Thanks for any help.  If needed I can join the code I already developed if necessary.

    Darrick

    You can read the file line by line and write back only if the length of the string <> 0.  (or maybe <> 1 in the case of the character line appears in the string to a blank line.)

    However, there is probably a way to change the code you have now so that he does not write blank lines.  Without seeing the code, it is difficult to help.

  • I need to create a table that has each increment of 15 minutes between the current date and time in the past.

    I can around the current datetime object to the the last quarter of an hour and show all dates for last year, but I'm looking for all the 15 minutes for each day of '1 October 13' to the current date.

    Here's what I have so far:

    SELECT

    trunc (sysdate, 'mi')-

    NUMTODSINTERVAL (mod (to_char (sysdate, 'mi'), 15), 'minute') as Quarter_Hr,

    (sysdate-365 (LEVEL-1)) AS DATES

    FROM DUAL connect by level < = (sysdate-(sysdate-365))

    Any help would be appreciated. I use that as a dimension table to evaluate performance on a base quarter of an hour.

    ALTER session set nls_date_format = "hh24:mi:ss dd/mm/yyyy '.

    /

    Select date "'2013-10-1 + (level - 1) / 96 dt"
    of the double
    connect by level<= trunc((sysdate="" -="" date="" '2013-10-1')="" *="" 96)="" +="">
    /

    DT
    -------------------
    01/10/2013 00:00:00
    01/10/2013 00:15:00
    01/10/2013 00:30:00
    01/10/2013 00:45:00
    01/10/2013-01:00
    01/10/2013-01:15
    01/10/2013-01:30
    01/10/2013-01:45
    01/10/2013-02:00
    01/10/2013-02:15
    01/10/2013-02:30

    DT
    -------------------
    01/10/2013-02:45
    01/10/2013-03:00
    01/10/2013-03:15
    01/10/2013-03:30
    01/10/2013 03:45
    01/10/2013 04:00
    01/10/2013-04:15
    01/10/2013-04:30
    01/10/2013-04:45
    01/10/2013-05:00
    01/10/2013-05:15

    .

    .

    .

    DT
    -------------------
    06/08/2014-11:45
    06/08/2014-12:00
    06/08/2014-12:15
    06/08/2014-12:30
    06/08/2014-12:45

    29716 selected lines.

    SQL >

    SY.

  • Difference between the true Date of the Hijra with date Hijri Oracle

    Hi all

    I'd appreciate if someone please let me the solution for this problem. In my application, I displays the Hijri Date using the NLS parameter. but the question that "I'm dealing with a deference between the date of the real Hijra with the date of the Hijra oracle."


    Assume that the actual Hijri date 18-SEP-2012 was 02/11/1433 in hijri but in oracle was 03/11/1433

    When I run the following query it shows me "1433/11/03", but the actual date of the Hijra is "" 1433/11/02.

    Select to_char (to_date ('20120918', 'YYYYMMDD'), ' DD/MM/YYYY', ' NLS_calendar = "' |') Hegira ARABIC ') FROM DUAL;


    IFTIKHAR

    Check

    FAQ on the calendar of the Hijra (Hijri) [ID 121061.1] Arabic
    and
    Conversion algorithm to Date in the Gregorian calendar until then Arab (Hijra) [ID 130551.1]

    Support of Oracle.

    If you have a file called lxecal.nlt file

    for Oracle 8 to $9i ORACLE_HOME/ocommon/sln
    for Oracle 10 g and more $ORACLE_HOME/nls

    so maybe that's the difference you see originally.

    Kind regards
    Bob

  • What is the difference between the sql statement

    What is the difference between below sql statements, get the output of these statements

    In the test table will have 55 columns

    Select count (*) from test_table

    Select count (1) into test_table

    Select count (10) into test_table

    Select count (100) in test_table

    Select count (100000) into test_table

    Thank you

    Published by: Balajiraam on December 28, 2011 20:51

    Published by: Balajiraam on December 28, 2011 21:02

    Hello
    This will be useful for you

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1156151916789 #25335122556076

    Kind regards
    Fame

  • effectiveness of the sql data warehouse and star/snowflake schema

    Hello

    We use 11.2.0.3 and need to improve the performance of queries for reports.  schema of data warehouse star/snowflake

    In addition to indexing, partitioning with star_transformation enabled etc I'm condisriing impact of the following on the performance of the queries.

    makes central (more than 1 billion lines) is associated with a client of dimesnion (a few hundred thousand lines) which in turn joined with the latest version of the dimesnion (includes approximately 30 000 lines).

    The table with a few hundred thousand lines (client dimesnion) alwsys must be questioned as stored data against the version of the customer at the time-, we wonder just latest_customer what users want to see

    the most recent version of the attributes of customer to stop data being fragemented through several lines in the report.

    If consideration would be more efficient to create a dimension that is equivalent to the customer but also stores the most recent version of the client attributes on the line-this means customer dimensuion many more columns but queries could would avoid additional research of this array of rank k 30.

    Thoughts are - it would be a material advantage?

    At the monent users request latest_customer to say would get all customers belonging to a certain multiple string.

    If change as above, then they would be interviewing the customer with a few hundred thousand lines dimension.

    Thoughts?

    Thank you

    Because a lot depends on the model of data access and data dissemination, we cannot really much more than only sb.  However, keep in mind Oracle accesses data by blocks (copies blocks and sometimes several blocks), in order to become more broad lines could have a paradoxical effect of not getting enough blocks in memory until you need it.

    It can help to visualize how data should be obtained (google something like visual sql and Karen Morton or Jonathan Lewis), as well as see the estimate and rowcounts actual imagined different plans.

  • Stuck between the SQL Setup and and SQL statement

    Hello

    There is an important application running on my system that is to
    MEMBER OF the service.

    First of all I would like to explain why I used MEMBERS ',
    I'll send a string (for example: #123 #124 #125) to the query and a function converts this string in an array of number.
    Then after I use this number inside my sql table.

    The reason I'm using this structure, in order to generate a dynamic IN the statement inside my sql. (IF you have another solution would be great)

    The most important point is; When I put this statement in the Setup SQL response is only ORA-00932: inconsistent data types: expected UDT got TANK

    Any response will be greatly appreciated.

    Thank you

    Object oriented stuff almost never provides better performance on the relationship. You should stay away FROM the MEMBER If performance is a factor. Instead of:

    WHERE expr MEMBER OF nested-table
    

    I would like to test:

    WHERE expr IN (SELECT column_value FROM TABLE(nested-table))
    

    SY.

  • Fill the drop-down list in the SQL data source

    I have a data source that retrieves data from an sqlite database. How do I pass two areas of this query to a drop-down list on the page. I want to create a drop down list with the value and the text of this data source

    Hello

    To extract the values you need to wait for onDataLoaded. "data" parameter is a list of cards.

    An example of code for data access :

    http://supportforums.BlackBerry.com/T5/Cascades-development/SQLite-count-query/m-p/2477699#M27180

    http://supportforums.BlackBerry.com/T5/Cascades-development/DataSource-data-in-JavaScript/m-p/244171...

    To add an option to the menu drop-down:

    attachedObjects: [
      ComponentDefinition {
        id: optionFactory
        Option {
        }
      }
    ]
    
    ... to add an option:
    
    var newOption = optionFactory.createObject()
    newOption.text = 'Text to add' // or a variable fetched from data source//newOption.otherfields = ...
    dropdownId.add(newOption);
    
  • Move vCenter base SQL Express to keep only the SQL data

    Hello, I found several articles on moving from sql express to full Sql but I have a few questions. Some of the items I fell on are: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 1028601 now, a question I have is, article mentions reinstating the vcenter DB but is the db RAS (Single Sign-on) and update DB Manager, they are all have to fly over on the new server by following the same instructions? I'm sure they do, but I was wondering if special measures or the restitution order is important. Thank you

    Exactly. Add it to the MSDB. You can remove only database after the installation/upgrade.

  • algorithm: show the relationships between the 2 data tables.

    I want to see '-connection path "between 2 tables given.
    Relationships of sample table:

    1 table a (ID)
    2. table B (ID A_ID), column "A_ID" has forced foreign key pointing to the column "A.ID.
    3. table C (ID, B_ID), points of 'B_ID' of column to column B in the table identifier.

    Entries in the algorithm: 'A' and 'C '.
    Outputs of the algorithm:
    ' (1) ' has '-of > 'B '->' C '.

    So put shorty that I give two strings as input to table names and identify those unique 2 lines in the table "user_tables. Now, these 2 tables have constraints of foreign keys pointing to some other tables in the database and possibly go through these pointers, so that we can draw 'A-> B-> C'. The relationship is defined somehow wuth series of paintings:
    USER_CONSTRAINTS
    USER_CONS_COLUMNS.

    How can I write this request carefully to see if 2 tales given have a relationship and how this relationship looks like, maybe there is way-table "B" or maybe C just of points in A.

    A very simple query, as bernyo said: use a hierarchical query:

        SELECT LEVEL, Parent_Table, Child_Table
          FROM (SELECT DISTINCT C2.Table_Name Parent_Table, C1.Table_Name Child_Table
                  FROM Dba_Constraints C1, Dba_Constraints C2
                 WHERE     C1.Owner = 'MYSCHEMA'
                       AND C1.Constraint_Type = 'R'
                       AND C2.Owner = C1.Owner
                       AND C2.Constraint_Type IN ('P','U')
                       AND C2.Constraint_Name = C1.R_Constraint_Name
                  )
    START WITH Parent_Table = 'MY_TABLE1'
    CONNECT BY PRIOR Child_Table = Parent_Table;
    

    : p

Maybe you are looking for