Query to return next 7 dates

Hello,
is there a way to return the next 7 dates just using a query... for example, I need a query that returns:
select (I don't know that put here) from dual
Date
2012-10-05
2012-10-06
2012-10-07
2012-10-08
2012-10-09
2012-10-10
2012-10-11
If possible, I would like to know if there's a way to pass a date and based on it, the query returns the next 7 dates based on the passed date... for example:
select (I don't know that put here) from dual where date > '2012-10-15'
Date
2012-10-16
2012-10-17
2012-10-18
2012-10-19
2012-10-20
2012-10-21
2012-10-22
I really appreciate any help
Thanks

Sven W. wrote:
I don't like connect by. That is fair enough, it is just your opinion.
It is slow and shouldn't be used for real production code.This however, is absolute garbage.
Changing the query to return 10,000 dates takes a little over 1s
SQL> select date '2012-10-15' + level - 1 from dual
  2  connect by level <= 10000;
<snip>
28-FEB-40
29-FEB-40
01-MAR-40
10000 rows selected.
Elapsed: 00:00:01.26>
In your case you can simply do this
with inputdata as (select to_date('2012-10-15','yyyy-mm-dd') startday from dual)
select startday+1 from inputdata union all
select startday+2 from inputdata union all
select startday+3 from inputdata union all
select startday+4 from inputdata union all
select startday+5 from inputdata union all
select startday+6 from inputdata union all
select startday+7 from inputdata ;
Running your alternative for 10,000 dates took quite some time to create, needed to be put in a file to execute and has been running now for about 15 minutes
select date '2012-10-15' + 1 from dual union all
select date '2012-10-15' + 2 from dual union all
<snip>
select date '2012-10-15' + 9996 from dual union all
select date '2012-10-15' + 9997 from dual union all
select date '2012-10-15' + 9998 from dual union all
select date '2012-10-15' + 9999 from dual union all
select date '2012-10-15' + 10000 from dual
;It is much more code, takes more time to write, is proven to be incredibly slow and shouldn't be used for real production code.
Edited by: 3360 on Oct 5, 2012 9:52 AM
Sorry it took only 12 minutes, it seemed a lot longer when waiting for it
29-FEB-40
01-MAR-40
01-MAR-40
02-MAR-40
10000 rows selected.
Elapsed: 00:12:01.35

Similar Messages

  • Query not returning all data

    All,
    I have 2 dimension tables and 1 logical fact table
    a01_bi_agency_interest_dim
    a01_bi_dsk_central_file_dim
    tier2_facts
    1 Complex Join in Physical Layer
    A01_BI_AGENCY_INTEREST_DIM.MASTER_AI_ID = A01_BI_DSK_CENTRAL_FILE_DIM.MASTER_AI_ID AND A01_BI_AGENCY_INTEREST_DIM.INT_DOC_ID = A01_BI_DSK_CENTRAL_FILE_DIM.INT_DOC_ID
    2 Logical Joins in BMM
    A01_BI_AGENCY_INTEREST_DIM to tier2_facts (inner, 0 or 1 to many)
    A01_BI_DSK_CENTRAL_FILE_DIM to tier2_facts (inner, 0 or 1 to many)
    Query only returns 1 row. Should return many rows, I have checked the data through sql queries in SqlPlus.
    Query from advanced tab.
    SELECT A01_BI_AGENCY_INTEREST_DIM.MASTER_AI_NAME saw_0,
    A01_BI_DSK_CENTRAL_FILE_DIM.INT_DOC_ID saw_1
    FROM TIER2 ORDER BY saw_0, saw_1
    Any help would be appreciated. I am missing something, but doesn't make sense.
    Thanks,
    Kathy

    It doesn't do the join and I get 1 record returned with zero's for both values. Why doesn't it pick up my join?
    -------------------- SQL Request:
    SET VARIABLE QUERY_SRC_CD='Report';SELECT A01_BI_AGENCY_INTEREST_DIM.MASTER_AI_ID saw_0, A01_BI_DSK_CENTRAL_FILE_DIM.INT_DOC_ID saw_1 FROM TIER2 ORDER BY saw_0, saw_1
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- General Query Info:
    Repository: Star, Subject Area: TIER2, Presentation: TIER2
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- Cache Hit on query:
    Matching Query:     SET VARIABLE QUERY_SRC_CD='Report';SELECT A01_BI_AGENCY_INTEREST_DIM.MASTER_AI_ID saw_0,
    A01_BI_DSK_CENTRAL_FILE_DIM.INT_DOC_ID saw_1
    FROM TIER2 ORDER BY saw_0, saw_1
    Created by:     Administrator
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- Query Status: Successful Completion
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- Physical Query Summary Stats: Number of physical queries 1, Cumulative time 0, DB-connect time 0 (seconds)
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- Rows returned to Client 1
    +++300000:300004:----2012/06/01 12:44:51
    -------------------- Logical Query Summary Stats: Elapsed time 0, Response time 0, Compilation time 0 (seconds)

  • ORA-19279 How do I write a query to return the data?

    I have XMLType tables in Oracle 11. I insert XML data from documents and each table only contains one XML document. I can write queries to return outer tags and inner tags but not outer and inner tags in the same result set. There can be one to many InvoiceLineRet tags to each InvoiceRet tag.
    Any and all help is appreciated.
    Mike
    This works and returns RefNumber for the invoice at the InvoiceRet level.
    SELECT
    a.RefNumber
    FROM InvoiceQueryRs xt,
    XMLTable('//InvoiceRet' PASSING xt.OBJECT_VALUE COLUMNS
    RefNumber VARCHAR2(255) PATH 'RefNumber') a;
    This works and returns the two columns from the InvoiceLineRet level.
    SELECT
    b.ILR_ItemRef_FullName,
    b.ILR_Desc
    FROM InvoiceQueryRs xt,
    XMLTable('//InvoiceLineRet' PASSING xt.OBJECT_VALUE COLUMNS
    ILR_ItemRef_FullName VARCHAR2(255) PATH 'ItemRef/FullName',
    ILR_Desc VARCHAR2(2000) PATH 'Desc') b
    But a query like this does not work.
    SELECT
    b.RefNumber,
    b.ILR_ItemRef_FullName,
    b.ILR_Desc
    FROM InvoiceQueryRs xt,
    XMLTable('//InvoiceRet' PASSING xt.OBJECT_VALUE COLUMNS
    RefNumber VARCHAR2(255) PATH 'RefNumber',
    ILR_ItemRef_FullName VARCHAR2(255) PATH 'InvoiceLineRet/ItemRef/FullName',
    ILR_Desc VARCHAR2(2000) PATH 'InvoiceLineRet/Desc') b
    This query returns data but every row has the same RefNumber.
    SELECT
    a.RefNumber,
    b.ILR_ItemRef_ListID,
    b.ILR_ItemRef_FullName,
    b.ILR_Desc
    FROM InvoiceQueryRs xt,
    XMLTable('//InvoiceRet' PASSING xt.OBJECT_VALUE COLUMNS
    RefNumber VARCHAR2(255) PATH 'RefNumber') a,
    XMLTable('//InvoiceLineRet' PASSING xt.OBJECT_VALUE COLUMNS
    ILR_ItemRef_ListID VARCHAR2(255) PATH 'ItemRef/ListID',
    ILR_ItemRef_FullName VARCHAR2(255) PATH 'ItemRef/FullName',
    ILR_Desc VARCHAR2(2000) PATH 'Desc') b
    Example of the XML:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
    <TEST>
         <InvoiceRet>
              <TxnID>D924-1210085400</TxnID>
              <TimeCreated>2008-05-06T10:50:00-05:00</TimeCreated>
              <TimeModified>2008-07-21T10:54:42-05:00</TimeModified>
              <EditSequence>1215638595</EditSequence>
              <TxnNumber>10398</TxnNumber>
              <CustomerRef>
                   <ListID>80000278-1209483158</ListID>
                   <FullName>Majestic Entries</FullName>
              </CustomerRef>
              <ARAccountRef>
                   <ListID>80000009-1185470478</ListID>
                   <FullName>Accounts Receivable</FullName>
              </ARAccountRef>
              <TemplateRef>
                   <ListID>80000019-1190228214</ListID>
                   <FullName>Compudoc</FullName>
              </TemplateRef>
              <TxnDate>2008-05-06</TxnDate>
              <RefNumber>22333</RefNumber>
              <BillAddress>
                   <Addr1>Majetic Entries</Addr1>
              </BillAddress>
              <BillAddressBlock>
                   <Addr1>Majetic Entries</Addr1>
              </BillAddressBlock>
              <IsPending>false</IsPending>
              <IsFinanceCharge>false</IsFinanceCharge>
              <DueDate>2008-05-06</DueDate>
              <ShipDate>2008-05-06</ShipDate>
              <Subtotal>391.50</Subtotal>
              <ItemSalesTaxRef>
                   <ListID>8000004F-1185996977</ListID>
                   <FullName>NC 7.25%</FullName>
              </ItemSalesTaxRef>
              <SalesTaxPercentage>7.25</SalesTaxPercentage>
              <SalesTaxTotal>5.73</SalesTaxTotal>
              <AppliedAmount>-397.23</AppliedAmount>
              <BalanceRemaining>0.00</BalanceRemaining>
              <IsPaid>true</IsPaid>
              <IsToBePrinted>false</IsToBePrinted>
              <IsToBeEmailed>false</IsToBeEmailed>
              <CustomerSalesTaxCodeRef>
                   <ListID>80000001-1185469345</ListID>
                   <FullName>Tax</FullName>
              </CustomerSalesTaxCodeRef>
              <InvoiceLineRet>
                   <TxnLineID>D926-1210085400</TxnLineID>
                   <ItemRef>
                        <ListID>80000059-1199714336</ListID>
                        <FullName>Labor:Non-Contract Labor Ken</FullName>
                   </ItemRef>
                   <Desc>Technical Labor performed by Ken Allen:
    Network Problem with Internet and intranet found two routers connected together and the one set for DHCP was bad we changed out their bad one with our small netgear router.</Desc>
                   <Quantity>1.5</Quantity>
                   <Rate>125.00</Rate>
                   <ClassRef>
                        <ListID>8000000D-1200208143</ListID>
                        <FullName>KA</FullName>
                   </ClassRef>
                   <Amount>187.50</Amount>
                   <ServiceDate>2008-04-28</ServiceDate>
                   <SalesTaxCodeRef>
                        <ListID>80000002-1185469345</ListID>
                        <FullName>Non</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>D927-1210085400</TxnLineID>
                   <ItemRef>
                        <ListID>80000029-1185470511</ListID>
                        <FullName>Labor:Non-Contract Labor Rick</FullName>
                   </ItemRef>
                   <Desc>Technical Labor performed by Rick Wagoner: Assisted with above troubleshooting</Desc>
                   <Quantity>1</Quantity>
                   <Rate>125.00</Rate>
                   <ClassRef>
                        <ListID>80000004-1185998300</ListID>
                        <FullName>RW</FullName>
                   </ClassRef>
                   <Amount>125.00</Amount>
                   <ServiceDate>2008-04-28</ServiceDate>
                   <SalesTaxCodeRef>
                        <ListID>80000002-1185469345</ListID>
                        <FullName>Non</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>D928-1210085400</TxnLineID>
                   <ItemRef>
                        <ListID>80000050-1185997340</ListID>
                        <FullName>Parts and Supplies</FullName>
                   </ItemRef>
                   <Desc>Parts and Supplies: Netgear router</Desc>
                   <Quantity>1</Quantity>
                   <Rate>79.00</Rate>
                   <ClassRef>
                        <ListID>80000007-1186694551</ListID>
                        <FullName>Parts</FullName>
                   </ClassRef>
                   <Amount>79.00</Amount>
                   <SalesTaxCodeRef>
                        <ListID>80000001-1185469345</ListID>
                        <FullName>Tax</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
         </InvoiceRet>
         <InvoiceRet>
              <TxnID>ED59-1216758177</TxnID>
              <TimeCreated>2008-07-22T16:22:57-05:00</TimeCreated>
              <TimeModified>2008-07-26T11:21:48-05:00</TimeModified>
              <EditSequence>1217085708</EditSequence>
              <TxnNumber>11203</TxnNumber>
              <CustomerRef>
                   <ListID>80000278-1209483158</ListID>
                   <FullName>Majestic Entries</FullName>
              </CustomerRef>
              <ARAccountRef>
                   <ListID>80000009-1185470478</ListID>
                   <FullName>Accounts Receivable</FullName>
              </ARAccountRef>
              <TemplateRef>
                   <ListID>80000019-1190228214</ListID>
                   <FullName>Compudoc</FullName>
              </TemplateRef>
              <TxnDate>2008-07-22</TxnDate>
              <RefNumber>22479</RefNumber>
              <BillAddress>
                   <Addr1>Majetic Entries</Addr1>
              </BillAddress>
              <BillAddressBlock>
                   <Addr1>Majetic Entries</Addr1>
              </BillAddressBlock>
              <IsPending>false</IsPending>
              <IsFinanceCharge>false</IsFinanceCharge>
              <DueDate>2008-07-22</DueDate>
              <ShipDate>2008-07-22</ShipDate>
              <Subtotal>839.00</Subtotal>
              <ItemSalesTaxRef>
                   <ListID>8000004F-1185996977</ListID>
                   <FullName>NC 7.25%</FullName>
              </ItemSalesTaxRef>
              <SalesTaxPercentage>7.25</SalesTaxPercentage>
              <SalesTaxTotal>33.64</SalesTaxTotal>
              <AppliedAmount>0.00</AppliedAmount>
              <BalanceRemaining>872.64</BalanceRemaining>
              <IsPaid>false</IsPaid>
              <IsToBePrinted>true</IsToBePrinted>
              <IsToBeEmailed>false</IsToBeEmailed>
              <CustomerSalesTaxCodeRef>
                   <ListID>80000001-1185469345</ListID>
                   <FullName>Tax</FullName>
              </CustomerSalesTaxCodeRef>
              <InvoiceLineRet>
                   <TxnLineID>ED5B-1216758177</TxnLineID>
                   <ItemRef>
                        <ListID>80000050-1185997340</ListID>
                        <FullName>Parts and Supplies</FullName>
                   </ItemRef>
                   <Desc>Parts and Supplies - Linksys Router</Desc>
                   <Quantity>1</Quantity>
                   <Rate>89.00</Rate>
                   <Amount>89.00</Amount>
                   <SalesTaxCodeRef>
                        <ListID>80000001-1185469345</ListID>
                        <FullName>Tax</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED5C-1216758177</TxnLineID>
                   <Desc>Suspect that the phone switch is attempting to act as a DHCP server for the network. per Terry, the reason that the phone switch was on the network was to supply VOIP to the warehouse phone lines. This was not working and is no longer needed. We removed the connection between the phone switch and the network.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED5D-1216758177</TxnLineID>
                   <Desc>Removed the Netgear router and the D-Link router. The D-Link had lost all settings and we could not log into the Netgear even after resetting to factory defaults.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED5E-1216758177</TxnLineID>
                   <Desc>Installed a new Lnksys router to replace the D-Link and Netgear faulty routers.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED5F-1216758177</TxnLineID>
                   <Desc>Ensured that all computers were connecting properly. Ensured that all computers printed to the Savin printer correctly.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED60-1216758177</TxnLineID>
                   <Desc>Worked with Time Warner Cable to resolve customer location and static IP.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED64-1216758177</TxnLineID>
                   <ItemRef>
                        <ListID>80000028-1185470511</ListID>
                        <FullName>Labor:Non-Contract Labor Kareem</FullName>
                   </ItemRef>
                   <Desc>Analyzed and resolved Internet connectivity problems after loss of service from Time Warner Cable.</Desc>
                   <Quantity>3</Quantity>
                   <Rate>125.00</Rate>
                   <Amount>375.00</Amount>
                   <ServiceDate>2008-07-22</ServiceDate>
                   <SalesTaxCodeRef>
                        <ListID>80000002-1185469345</ListID>
                        <FullName>Non</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED68-1216758177</TxnLineID>
                   <ItemRef>
                        <ListID>8000005D-1216758445</ListID>
                        <FullName>Labor:Non-Contract Labor Mike</FullName>
                   </ItemRef>
                   <Desc>Analyzed and resolved Internet connectivity problems after loss of service from Time Warner Cable.</Desc>
                   <Quantity>3</Quantity>
                   <Rate>125.00</Rate>
                   <Amount>375.00</Amount>
                   <ServiceDate>2008-07-22</ServiceDate>
                   <SalesTaxCodeRef>
                        <ListID>80000001-1185469345</ListID>
                        <FullName>Tax</FullName>
                   </SalesTaxCodeRef>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED94-1216758177</TxnLineID>
                   <Desc>Terry called, cannot connect to internet. Everyone but Terry can connect. Terry is getting a 172 IP address on his laptop. Walked him through putting a static IP on his laptop so that he could be functional. I went to their site and talked with the NEC phone switch management company. They said the switch does not have DHCP capabilities. I could not duplicate Terry's issue using my laptop. The phone switch is now totally disconnected from the network since the VOIP setup for the warehouse was not functional. Validated that the TWC modem is not DHCP.</Desc>
                   <ServiceDate>2008-07-23</ServiceDate>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>ED95-1216758177</TxnLineID>
                   <Desc>Requires further diagnostics on Friday the 25th (if Terry is available) - need his laptop on-site to diagnose the problem.</Desc>
              </InvoiceLineRet>
              <InvoiceLineRet>
                   <TxnLineID>EE30-1216758177</TxnLineID>
                   <Desc>Communicated with Terry on 7/24/2008 via email. He is using DHCP and connecting correctly. Removing the final connection from the phone switch to the network appears to have corrected the problem.</Desc>
                   <ServiceDate>2008-07-24</ServiceDate>
              </InvoiceLineRet>
         </InvoiceRet>
    </TEST>

    Never mind. I figured it out.

  • Return default data if no data is returned by sql query

    Hi,
    I have a requirement.
    I have an inner query that returns no data. However I still want to return default data (say 'abc'). The below sql does not return anything inspite of using nvl . Please advise .
    select nvl( x.vencode,'abc') vencode
    from
    -- below sql returns no data!
              SELECT a.vencode vencode,
                     a.mid mid,
                     a.title title,
                      ROW_NUMBER() OVER (PARTITION BY a.vencode ORDER BY a.title) rnk
               FROM (
                     SELECT *
                     FROM    (SELECT vencode FROM vendor where login is not null and vencode = 'BKFI'
                                        and login > (sysdate - 90) )
                          CROSS JOIN
                             (SELECT mid, title, ROWNUM num FROM tcommmemos where mid is not null)
                    ) a,        
                   (SELECT * FROM (
                    SELECT v.vencode, tc.mid, tc.title
               FROM
               (select  * from vendor
                     where login is not null and vencode = 'BKFI'
                     and login > (sysdate - 90)) v,
                tcommmemosviewed tcv, tcommmemos tc
               WHERE     v.vencode = tcv.vencode
                     and tc.mid is not null
                     --AND tc.post_date > v.hiredate
                     AND tc.mid = tcv.mid)
                   ) b
                   where a.vencode = b.vencode(+)
                     and a.title   = b.title(+)
                     and a.mid     = b.mid(+)
                     and b.mid is null                               
    ) x              

    Use any aggregate function it'll always return a value even if there no data in the table
    create table r_dummy_1 (a number);
    SQL> select * from r_dummy_1;
    no rows selected
    SQL> select nvl(max(a),1) from r_dummy_1;
    NVL(MAX(A),1)
    1

  • Query for file version less than 10.0 does not return expected data

    I'm trying to build a query for all PCs that have a version of Iexplore.exe in c:\windows\program files\ that is less than 10.0 .  When I run the query it returns no data. When I change 10.0 in the query to 9.9 it returns files with version 10.xxx in
    the results.  Its as if it is seeing 10.0 as 1.0.   Is this expected ?
    select SMS_R_System.Name, SMS_R_System.ADSiteName, SMS_G_System_SoftwareFile.FileName, SMS_G_System_SoftwareFile.FileVersion from  SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where
    SMS_G_System_SoftwareFile.FileName = "iexplore.exe" and SMS_G_System_SoftwareFile.FilePath = "C:\\program files\\internet explorer\\" and SMS_G_System_SoftwareFile.FileVersion < "9.9"

    It is because the values are not integer, they are a string. And therefore 1 is smaller then 9.
    http://www.enhansoft.com/

  • Returning XML Data from a database

    Ok, just got the new DW CS3 and really want to begin using
    the built in Spry capabilitites. All of the examples I've seen for
    populating the datasets with XML data are based on referencing a
    static XML file. I want to query my database and return XML data to
    a Spry Table. How do I accomplish this? I know how to perform the
    query and retrun the data in an XML format (ColdFusion) but I can't
    tell the spry dataset to use this. HELP!!

    Well, that's the trick... I can't point to a testing server
    (i.e. Application interface) because we aren't permitted to have
    the RDS login where I work. (They haven't bothered to configure the
    CF server for restricting access) I have to manually create all
    connections and queries. I'm currenlty using the exact format in
    the example page you provided to return the data in an XML format
    but when I point to that file as my datasource I get nothing
    displayed on the page. The file that performs the query and returns
    the data is in a separate file from the one I'm trying to use the
    Spry table in. When I use this same query file for an Ajax call to,
    say, populate a listbox or pulldown menu it works fine, but I can't
    get it to work with the Spry dataset.

  • MDX Query not retuern any data on my production server when i check service it is running

    Hi All,
    MDX Query not return any data  on my production server when i check service it is running. when i restart my service  i can able to run MDX Query and get data in my production server.

    Hi Mnishcal,
    According to your description, there is no data returned before restart Analysis Services, right?
    We haven't experiencing such issue before. And we cannot reproduce this issue. In your scenario, can you reproduce this issue? Here is a post which explains why you might not see the data you expect when browsing a SQL Server Analysis Services cube that
    processed successfully. Please refer to the link below.
    http://social.technet.microsoft.com/wiki/contents/articles/19744.ssas-troubleshooting-data-is-not-visible-when-browsing-a-cube.aspx
    Besides, are there any error on the log file? The msmdsrv.log file for the SSAS instance that can be found in \log folder of the instance. (C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Log)
    Regards,
    Charlie Liao
    TechNet Community Support

  • Using external parameters within MS Query returning that data right into a pivot table Excel 2010

    In Excel 2010 i was able to use the external parameters within MS Query returning that data right into a pivot table.  But the parameter on the worksheet will not save in the paremeter setting of the data connection.  And if you save it and open
    it and try to refresh the pivot table Excel stops responding and you have to force the file closed.  I found out the reason to crash is that it did not keep the parameter saved.
    Can this be fixed?

    Hi,
    Just
    checking in to see if the information of Oskar was helpful. Please
    let us know if you would like further assistance.
    Jaynet Zhang
    TechNet Community Support

  • QUERY TO PRINT THE DATE OF NEXT FRIDAY THAT IS SIX MONTHS FROM TODAY

    CAN ANY PLZ LET ME KNOW THE QUERY TO PRINT THE DATE OF NEXT FRIDAY THAT IS SIX MONTHS FROM TODAY.THE OUTPUT DATE FORMAT SHOULD BE AS SHOWN IN THE EXAMPLE.
    (Eg) : TODAY: 24-FEB-09          
    NEXT_FRIDAY_AFTER_SIX_MONTHS: 28-AUG-2009 (FRIDAY)
    USING DUAL TABLE

    Laurent Schneider wrote:
    yes, but when I create a view, I cannot guarantee that every client accessing this view will be using English, can I?You're in an environment where you can't guarentee that, I agree. I'm in an environment where I very luckily can guarentee it. But in general, I take your point *{:-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • OTL I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?

    Hi
    I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
    I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
    Thanks
    Ruby

    Ruby,
    you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP.

  • How to optimize query that returns data based on one matching and one missing field joining two tables

    Hi all,
    Here is what I am trying to do. I have 2 tables A and B. Both have a fiscal year and a school ID column. I want to return all data from table B where all school IDs match but fiscal year from A is not in B. I wrote 2 queries below but this took
    2 minutes each to process through 30,000 records in table B. Need to optmize this query.
    1) select 1 from table A inner join table B
    on A.SchoolID=B.SchoolID where A.Year not in (select distinct Year from table B)
    2) select distinct Year from Table A where School ID in (select distinct School ID from table B
    and Year not in (select distinct Year from table B)

    Faraz81,
    query execution time will depend not only on your data volume and structure but also on your system resources.
    You should post your execution plans and DDL to generate data structures so we can take a better look, but one think you could try right away is to store the results of the subquery in a table variable and use it instead.
    You'll also benefit from the creation of:
    1. An index for the B.SchoolID column.
    2. Statistics for the Year column in table B.
    You can also try to change the physical algorithm used to join A to B by using query hints (HASH, MERGE, LOOP) and see how they perform. For example:
    select 1 from table A inner HASH join table B
    on A.SchoolID=B.SchoolID where A.Year not in (select distinct Year from table B)
    As the query optimizer generally chooses the best plan, this might not be a good idea though, but then again, without further information its going to be hard to help you.

  • Return all data without selecting any value in query filter

    Hi,
    I created a document with query filters(prompt, LOV). But sometimes users don't want to select any value and just want to return all data in the report.
    I can't find a way to achieve this. Does anyone know how to implement this ?
    Thanks.

    Hi,
    you can modify the "select" statement for your LOV and add an additionaly keyword like "ALL" in your list of values. Then you can modify your where-clause to handle the "ALL" keyword.
    E.g. (<your condition>=@prompt(....) or 'ALL'=@prompt(......) )
    Regards,
    Stratos

  • Discoverer Report  returning ' no data  found '

    Hi  ...
    i  have an issue with one discoverer  report  .
    Discoverer report  name : EDI Price Exception Report.
    when i ran the report  in Discoverer  Desktop edition  It is returning 'No Data Found ' But  i am taken the  Query from admin edition  and tried to  ran in  PL/SQL Developer/TOAD  by setting  Org_id condition
    it's returning Data  . the Desktop Edition of Discoverer for  some specific date  Range  it's giving Data  But  from last month on wards  it's not returning any Data.
    in Discoverer Report  Desktop  it's not retuning the Data from  November to till date
    Oracle  Applications  11i
    Discoverer 4i
    Oracle Data base :9i 
    OS : Windows.
    Attached the Sql  which i used to generate the Report :
    I HAVE USED THE FOLLOWING  :-for initialize the profile options
    EXEC FND_GLOBAL.APPS_INITIALIZE (0,52163,660);
    EXEC APPS.FND_CLIENT_INFO.SET_ORG_CONTEXT(2922);
      SELECT A.CUST_PO_NUMBER,
             A.ORDER_NUMBER,
             A.ORDERED_DATE,
             A.ORDER_TYPE,
             -- C.CUSTOMER_ID,
             C.CUSTOMER_NUMBER,
             C.CUSTOMER_NAME,
             B.LINE_NUMBER,
             B.ORDERED_ITEM,
             MSI.SEGMENT1 ACCO_ITEM,                               -- GRW 20060407
             MSI.DESCRIPTION,
             -- MSI.INVENTORY_ITEM_ID,
             (SELECT MCI.CUSTOMER_ITEM_NUMBER
                FROM MTL_CUSTOMER_ITEMS MCI,
                     MTL_CUSTOMER_ITEM_XREFS MCIX,
                     MTL_SYSTEM_ITEMS_B MSIB
               --  MTL_PARAMETERS          MP
               WHERE     MCI.CUSTOMER_ID = C.CUSTOMER_ID                 --1814924
                     AND MCI.CUSTOMER_ITEM_ID = MCIX.CUSTOMER_ITEM_ID
                     AND MCIX.INVENTORY_ITEM_ID = MSIB.INVENTORY_ITEM_ID
                     AND MSIB.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID   --869899
                     AND MSIB.ORGANIZATION_ID = MTP.ORGANIZATION_ID --MP.ORGANIZATION_ID
                     AND MTP.ORGANIZATION_CODE = 'BRM'
                     AND MCI.CUSTOMER_ITEM_NUMBER = B.ORDERED_ITEM
                     AND NVL (mci.inactive_flag, 'N') <> 'Y'
                     AND NVL (mcix.inactive_flag, 'N') <> 'Y')
                CUSTOMER_ITEM,
                     XXAB_ITEM_XREFS.GET_GBC_ITEM_NUM (B.ORDERED_ITEM) GBC_ITEM_NUMBER,
             B.ORDERED_QUANTITY,
             B.PRICE_LIST,
             B.UNIT_SELLING_PRICE,
             B.UNIT_LIST_PRICE,
                   TO_NUMBER (B.ATTRIBUTE7) CUST_SENT_PRICE,
             apps.XXAB_CUST_SENT_PRICE_CONV_SO (C.customer_number,
                                                B.ordered_item,
                                                B.header_id,
                                                B.line_number,
                                                B.unit_selling_price,
                                                B.attribute7,
                                                B.pricing_quantity_uom,
                                                B.attribute4)
                CUST_SENT_PRICE_CONVERTED,
             ABS ( (B.UNIT_SELLING_PRICE
                    - apps.XXAB_CUST_SENT_PRICE_CONV_SO (C.customer_number,
                                                         B.ordered_item,
                                                         B.header_id,
                                                         B.line_number,
                                                         B.unit_selling_price,
                                                         B.attribute7,
                                                         B.pricing_quantity_uom,
                                                         B.attribute4)))
                DIFFERENCE,
                      MTP.ORGANIZATION_CODE,
             B.SHIP_TO_LOCATION
        FROM OE_ORDER_HEADERS_V A,
             OE_ORDER_LINES_V B,
             RA_CUSTOMERS C,
             MTL_PARAMETERS MTP,
             MTL_SYSTEM_ITEMS_B MSI
       WHERE     A.HEADER_ID = B.HEADER_ID
             AND A.SOLD_TO_ORG_ID = C.CUSTOMER_ID
             -- Added by Gati on 19-Oct-2012, tkt - INC000000118962
             AND ROUND (TO_NUMBER (apps.XXAB_CUST_SENT_PRICE_CONV_SO (
                                      C.customer_number,
                                      B.ordered_item,
                                      B.header_id,
                                      B.line_number,
                                      B.unit_selling_price,
                                      B.attribute7,
                                      B.pricing_quantity_uom,
                                      B.attribute4)),
                        2) <> B.UNIT_SELLING_PRICE
             --AND ROUND(TO_NUMBER(B.ATTRIBUTE7), 2) <> B.UNIT_SELLING_PRICE
             --AND     a.ship_from_org_id = mtp.organization_id
             AND B.SHIP_FROM_ORG_ID = MTP.ORGANIZATION_ID          -- GRW 20060413
             --AND     a.ship_from_org_id = msi.organization_id
             AND B.SHIP_FROM_ORG_ID = MSI.ORGANIZATION_ID          -- GRW 20060413
             AND B.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID       -- GRW 20060407
             AND A.ORDER_SOURCE_ID = 6
             AND A.ORG_ID = B.ORG_ID
             AND TO_CHAR (A.ordered_date, 'DD-MON-YYYY') between  '01-NOV-2013' and  '03-NOV-2013'
             and mtP.organization_code='BRM'
                      AND A.ORG_ID = (SELECT HOU.ORGANIZATION_ID
                               FROM HR_OPERATING_UNITS HOU
                              WHERE HOU.NAME = '50 ACCO Canada')
             AND B.cancelled_flag <> 'Y'
             AND B.flow_status_code <> 'CANCELLED'
             AND B.ORDERED_ITEM <> 'INVALID_ITEM'
    ORDER BY a.order_number

    Hi,
    Assuming your initialization matches your discoverer login, it is pretty weird that you get no data.
    I am not sure how you got the SQL but i suggest you trace the session to get the exact SQL ran by the discoverer.
    You may find another condition or join that limits your data.
    Also another thing that you should try is to initial the session by using all the parameters (including the security group as you have in your discoverer login):
    begin
      fnd_global.APPS_INITIALIZE(user_id =>, resp_id =>, resp_appl_id =>, security_group_id =>);
    end

  • Discoverer report returns no data from a certain time

    Using Discoverer 10g,a discoverer report which returned data normally last month gets to return no data now.
    We have four same environments, and two of them has this problem, two is OK.
    And the SQL of the discoverer of the four environments are the same.
    We have no any changment of this discoverer and related EUL for more than one year....
    How should we investigate into this issue.
    For example ,a point we should notice or something...
    Could somebody give us a suggestion?
    Thank you.

    Thanks for your qiuck reply.
    1.empty table that is joined in the query.The four environments has almost the same data,it is not the cause.
    2.security issue with the data, maybe the security definitions are different from one environment to another.we are now invesgate into this cause.
    and there is a sql of the discoverer's EUL which shows no data in a enviroment(in this enviroment discoverer report gets no data), but in another enviroment data can show.
    the sql is as following.
    =============
    SELECT loc_bu.org_id
    ,loc_bu.location_id building_id
    ,loc_bu.building building_name
    ,loc_bu.location_code building_number
    ,loc_fl.location_id floor_id
    ,loc_fl.location_code floor_number
    ,loc_fl.floor floor_name
    ,loc_of.location_id office_id
    ,loc_of.location_code office_number
    ,loc_of.office office_name
    ,loc_of.suite office_suite
    ,loc_of.location_alias office_alias
    ,loc_of.assignable_area office_assignable_area
    ,loc_of.space_type_lookup_code office_space_type_code
    ,lst.meaning office_space_type
    ,loc_of.function_type_lookup_code office_function_type_code
    ,fun.meaning office_function_type
    ,(SELECT ffv.description
    FROM fnd_flex_values_vl ffv
    ,fnd_flex_value_sets ffvs
    WHERE ffv.flex_value = loc_of.attribute1
    AND ffv.flex_value_set_id = ffvs.flex_value_set_id
    AND ffvs.flex_value_set_name = 'MB_PN_ON') occupancy_exception_flag
    ,loc_of.active_start_date
    ,loc_of.active_end_date
    --ADD BY KEVIN 2008/6/26 START
    ,loc_of.attribute7 division_code_office
    ,(SELECT ffv.description
    FROM fnd_flex_values_vl ffv
    ,fnd_flex_value_sets ffvs
    WHERE ffv.flex_value = loc_of.attribute7
    AND ffv.flex_value_set_id = ffvs.flex_value_set_id
    AND ffvs.flex_value_set_name = 'MB_PN_DIVISION') division_description_office --ヌヨ-ホ・ヒオテ・
    --ADD BY KEVIN 2008/6/26 END 
    FROM pn_locations loc_bu
    ,pn_locations loc_fl
    ,pn_locations loc_of
    ,fnd_lookups fun
    ,fnd_lookups lst
    WHERE loc_bu.location_id = loc_fl.parent_location_id
    AND loc_bu.location_type_lookup_code IN ('LAND', 'BUILDING')
    AND nvl(loc_bu.attribute6, '99') <> '01'
    AND loc_fl.location_id = loc_of.parent_location_id
    AND loc_fl.location_type_lookup_code IN ('FLOOR', 'PARCEL')
    AND nvl(loc_fl.attribute6, '99') <> '01'
    AND loc_of.location_type_lookup_code IN ('OFFICE', 'SECTION')
    AND nvl(loc_of.attribute6, '99') <> '01'
    AND loc_of.function_type_lookup_code = fun.lookup_code(+)
    AND fun.lookup_type(+) = 'PN_FUNCTION_TYPE'
    AND loc_of.space_type_lookup_code = lst.lookup_code(+)
    AND lst.lookup_type(+) = decode(loc_of.location_type_lookup_code,
    'OFFICE',
    'PN_SPACE_TYPE',
    'SECTION',
    'PN_PARCEL_TYPE')
    AND nvl(loc_of.space_type_lookup_code,'99') <> '07';
    ====================
    Ps.before excute this sql, we always first excute following command.
    ====
    begin
    fnd_client_info.set_org_context(117);
    end;
    ====
    The analyst of our team is not very good at the security problem, could you help us?
    Thanks a lot.

  • Query to return ALL rows even those with zero counts

    Hi,
    The following query will return only those rows that have a non zero count value:
    select c.id, a.name, count(*) as XYZ from CON c, CUST a
    where c.help !='1' and (c.id = a.id) group by c.id, a.name order by c.id;
    The results are:
    1 ME 3
    3 YOU 4
    What i want is to return all rows in CUST and the count, XYZ, that correspond to each row in CUST that matches the whare condition above, even if the count is zero.
    ie
    1 ME 3
    2 WE 0
    3 YOU 4
    Can this be done?

    You may want to get the counts then do the outer join. If you simply count with an outer join you will get 1 for 'WE' because there is a row in the cust table with 'WE'. This may work for you;
    with
      cust as (
       select 1 id, 'ME' name from dual union all
       select 2 id, 'YOU' name from dual union all
       select 3 id, 'WE' name from dual),
      con as (
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual)
    -- end of test data 
    select a.id, a.name, nvl(c.cnt,0) xyz
    from cust a, 
       (select id, help, count(*) cnt
       from con
       where help !='1'
       group by id, help) c
    where a.id = c.id(+)

Maybe you are looking for