Query for an in between date

I need to make a query that checks to see if the start_date is less than sysdate and the end_date is greater than sysdate
SELECT * FROM table WHERE OFFICE_START_DATE < SYSDATE AND OFFICE_END_DATE > SYSDATE
What is the easiest way of doing this?
Thanks

user9179751 wrote:
It wasn't working for me initially but I had to format the date to validate.
SELECT * FROM TABLE WHERE OFFICE_START_DATE < TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')
AND OFFICE_END_DATE > TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS');As skvaish said, it looks as if your columns are character (varchar2, most likely) and not dates. And if so, your solution is still buggy. You should be doing
select *
from mytable
where to_date(office_start_date) < sysdate
  and  to_date(office_end_date) > sysdate;If you insist on thinking that a chracter string that looks like a date is a date, what do you make of this:
First, create a table with a char column used as a date:
SQL> drop table mydemo;
Table dropped.
SQL> create table mydemo (
  2  alfa_date varchar2(11),
  3  rite_date date
  4  );
Table created.Now insert some data
SQL> --
SQL> insert into mydemo values ('01-JAN-2010', to_date('01-JAN-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('01-FEB-2010', to_date('01-FEB-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('01-APR-2010', to_date('01-APR-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('02-JAN-2010', to_date('02-JAN-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('02-FEB-2010', to_date('02-FEB-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('02-APR-2010', to_date('02-APR-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('03-JAN-2010', to_date('03-JAN-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('03-FEB-2010', to_date('03-FEB-2010','DD-MON-YYYY'));
1 row created.
SQL> insert into mydemo values ('03-APR-2010', to_date('03-APR-2010','DD-MON-YYYY'));
1 row created.
SQL> commit;
Commit complete.Now, select, and order on the alfa-date;
SQL> select * from mydemo order by alfa_date;
ALFA_DATE   RITE_DATE
01-APR-2010 01-APR-10
01-FEB-2010 01-FEB-10
01-JAN-2010 01-JAN-10
02-APR-2010 02-APR-10
02-FEB-2010 02-FEB-10
02-JAN-2010 02-JAN-10
03-APR-2010 03-APR-10
03-FEB-2010 03-FEB-10
03-JAN-2010 03-JAN-10
9 rows selected.Are they in date sequence?
No they are not.
Why not?
Now select, and order on the properly defined date column.
SQL> select * from mydemo order by rite_date;
ALFA_DATE   RITE_DATE
01-JAN-2010 01-JAN-10
02-JAN-2010 02-JAN-10
03-JAN-2010 03-JAN-10
01-FEB-2010 01-FEB-10
02-FEB-2010 02-FEB-10
03-FEB-2010 03-FEB-10
01-APR-2010 01-APR-10
02-APR-2010 02-APR-10
03-APR-2010 03-APR-10
9 rows selected.
SQL> spo off

Similar Messages

  • MDX query for to get the data from two cubes

    Hi
    Can you tell me how to create MDX query to get the values from two cubes.  (One hierarchy from first cube and one hierarchy from second cube)
    Can you give me one example.
    Regards,
    Madhu.
    Sudhan

    Hi Sudhan,
    According to your description, you want to retrieve data from two different cubes, right? The short answer is yes. To query multiple cubes from a single MDX statement use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    Regards,
    Charlie Liao
    TechNet Community Support

  • Query For Xquery Implementation of Date Function

    Hi All,
    Objective: In array Item, I have to check for device entry Dates.
    First device entry date would be the date corresponding to device seq no =0
    Latest entry date would be the date corresponding to max device seq no.
    Diff date should be differnce between first entry date and latest entry dates in days.
    Output should be like
    <FirstEntrydate></FirstEntrydate>
    <LatestEntryDate></LatestEntryDate>
    <Diffdate></Diffdate>
    <Maxdevice Seq no></MaxdeviceSeqno>
    the XML to transform is :
    <?xml version="1.0"?>
    <ns0:contractDeviceHistory xmlns:ns0="http://www.lhsgroup.com/ws_v3">
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2015-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2013-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>2</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2014-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2013-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>1</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2012-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2012-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>0.0</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    </ns0:contractDeviceHistory>
    The Incomplete Xquery i wrote is this, which is not working. Plz suggest
    declare function xf:SIMReplacementInfoResBSCSToSiebel($contractDeviceHistory1 as element())
    as element(ns0:SIMReplacementResponse) {
    <ns0:SIMReplacementResponse>
    <ns0:SIMReplacement>
    for $item in $contractDeviceHistory1/ns1:item
    group $item as $group by
                   $item/ns1:deviceSeqno as $key1,
                        $item/ns1:deviceEntryDate/ns1:date as $key2
                   order by $key1 descending
    return
    <ns0:SIMReplacement
    MaxDeviceSeqNo= "{ fn:max($key1) }"
    FirstEntry_date = "{if(($key1) = '0.0')then($key2) else (0)}"
    LatestEntry_date="{if(($key1)= fn:max($key1))then($key2) else ($key2)}"
    /> }
    <ns0:Status>Success</ns0:Status>
    </ns0:SIMReplacement>
    </ns0:SIMReplacementResponse>
    declare variable $contractDeviceHistory1 as element() external;
    xf:SIMReplacementInfoResBSCSToSiebel($contractDeviceHistory1)
    Regards
    Manu
    India.

    Post Author: jsiegmund
    CA Forum: Data Connectivity and SQL
    Not really, that function is a start, but to calculate the true ammount of work days there are a lot more variables to take into account. For instance, easter depends on the easter sunday which isn't a fixed date. In one year it may be in may, in the next it's in april. So defining a list of holidays (as done in the function in your example) isn't going to cut it. Therefore I mentioned implementing the function in Crystal Reports is a hard job which I wouldn't gladly take on. In the meantime, I've come upon an other solution using SQL Server 2005. It's possible to use assembly's in SQL Server, so I compiled the function as an assembly and loaded that into SQL Server. I needed information from the database for my reports anyway, so now I'm able to do the calculations in the views in the database, instead of leaving that to Crystal. Somewhat of a different solution, but it works for now. It would be great if future versions of Crystal would support the loading of assembly files though

  • Function Module for calculating hours between dates and their times.

    Hi all,
    Is there any standard function module for calculating the time difference in hours between two dates with start and end times.
    Regards,
    Sudipto.

    Sudipto,
    How're you ????????????????????
    Check out the following Function Module:
    SD_DATETIME_DIFFERENCE (Give the difference in Days and Time for 2 dates)
    Regards,
    Abir
    Don't forget to award Points *

  • ImplementationOpt Design[Opt 31-67] Problem for AXI bus between data mover ip and axi interconnect

    I'm using vivado 2014.4 and win7 64bit for my zynq design.  Previously, the design is good. I made some revisions. Then I came across the problem.
    If the synthesis strategies option is flow_runtime_optimatized(Vivadio synthesis 2014), everything works
    If the synthesis  strategies option is default options (the synthesis settings are shown in the picture), Synthesis is still fine, but the implementation failed. Some of the errror msg is shown below.
    The error message shows there are unconnected pins on axi_interconnect_1. The connections between AXI master from my own IP(it is the axi port from a DataMover IP) and axi_interconnected is shown in the attached picture.
    The synthesis schematic is also checked. The connections of the axi_interconnect have some pins unconnected as shown in the picture (interconnect_schematic_synth.PNG). The connections of my IP are good, but it misses some pins (like _arready, _rvalid, _ruser, _bid...).  The master AXI port in my port is from the data mover IP. By default, the data mover IP doesn't have these missed pins. The AXI port on my IP declares these missed pins, but actually they are not connected to any inside my IP. 
    Btw, previously, the project works well in my design. But now it doesn't.
     I also check the connections of the axi_interconnect when synthesis strategies option is flow_runtime_optimatized, the schematic show all pins are connected. 
    Please help. Thx.
    Sam
    ImplementationOpt Design[Opt 31-67] Problem: A LUT1 cell in the design is missing a connection on input pin I0, which is used by the LUT equation. This pin has either been left unconnected in the design or the connection was removed due to the trimming of unused logic. The LUT cell name is: design_top_level_i/Zynq_Processing_System/axi_interconnect_1/s00_couplers/auto_pc/inst/gen_axi4_axi3.axi3_conv_inst/USE_READ.USE_SPLIT_R.read_addr_inst/size_mask_q[3]_i_1__0.
    [Opt 31-67] Problem: A LUT2 cell in the design is missing a connection on input pin I0, which is used by the LUT equation. This pin has either been left unconnected in the design or the connection was removed due to the trimming of unused logic. The LUT cell name is: design_top_level_i/Zynq_Processing_System/axi_interconnect_1/s00_couplers/auto_pc/inst/gen_axi4_axi3.axi3_conv_inst/USE_READ.USE_SPLIT_R.read_addr_inst/access_is_incr_q_i_1__0.
    [Opt 31-67] Problem: A LUT2 cell in the design is missing a connection on input pin I1, which is used by the LUT equation. This pin has either been left unconnected in the design or the connection was removed due to the trimming of unused logic. The LUT cell name is: design_top_level_i/Zynq_Processing_System/axi_interconnect_1/s00_couplers/auto_pc/inst/gen_axi4_axi3.axi3_conv_inst/USE_READ.USE_SPLIT_R.read_addr_inst/access_is_incr_q_i_1__0.
    [Opt 31-67] Problem: A LUT2 cell in the design is missing a connection on input pin I0, which is used by the LUT equation. This pin has either been left unconnected in the design or the connection was removed due to the trimming of unused logic. The LUT cell name is: design_top_level_i/Zynq_Processing_System/axi_interconnect_1/s00_couplers/auto_pc/inst/gen_axi4_axi3.axi3_conv_inst/USE_READ.USE_SPLIT_R.read_addr_inst/command_ongoing_i_2__0.
    [Opt 31-67] Problem: A LUT2 cell in the design is missing a connection on input pin I0, which is used by the LUT equation. This pin has either been left unconnected in the design or the connection was removed due to the trimming of unused logic. The LUT cell name is: design_top_level_i/Zynq_Processing_System/axi_interconnect_1/s00_couplers/auto_pc/inst/gen_axi4_axi3.axi3_conv_inst/USE_READ.USE_SPLIT_R.read_addr_inst/size_mask_q[1]_i_1__0.
    [Opt 31-67] Problem:

     
    Hi Muzaffer
    THx for your reply. 
    I tried implementation with opt_design option -directive Explore, it didn't work.
    Aslo I disabled the opt_design and enabled phys_opt_design, it still has the same error in the implementation.
    I would try to delete the pins related  _AR_(like _arready, etc. ) and _R_ (like _rdata, _rid, etc.) pins in the AXI4 port in my IP. The data mover ip doesn't contains thes pins. I want  to see whether it works this way.
    Hopefully, the new vivado version will help. 

  • Query For Large Amount of Data

    Hello All,
    I apologize in advance if I am not posting this in the right section. I am fairly new to APEX and database designing. My goal is to create an inquiry screen for a database of people.
    I am running APEX 4.2 on 11g. The information is store in 3 tables; Names, Demographics, Address. Each table had a PIN ID column that ties them all together. Each table has almost a million rows in them.
    Currently I have it set up that the person types in the name they want to search and it gets passed into a hidden page item on the next page where there is a report with a select statement based on the page item. Everything works right now however it is slow. I am having a 5-10 second delay before the results come up.
    My question is, is there a better way to set up these tables. What is the best way to make this faster?
    I'm sorry if this is a vague question but any help, or point in the right direction will be greatly appreciated
    Thank You !

    976533 wrote:
    Hello All,Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "976533".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I apologize in advance if I am not posting this in the right section. I am fairly new to APEX and database designing. My goal is to create an inquiry screen for a database of people.It might be more appropriate to the {forum:id=75} forum, so you should look at the following entries on their FAQ as well:
    <li>{message:id=9360002}
    <li>{message:id=9360003}
    I am running APEX 4.2 on 11g. The information is store in 3 tables; Names, Demographics, Address. Each table had a PIN ID column that ties them all together. Each table has almost a million rows in them.
    Currently I have it set up that the person types in the name they want to search and it gets passed into a hidden page item on the next page where there is a report with a select statement based on the page item. Everything works right now however it is slow. I am having a 5-10 second delay before the results come up.
    My question is, is there a better way to set up these tables. What is the best way to make this faster? Are there suitable indexes on the tables?
    Does the report query use them?
    As described above, either: reproduce the problem on apex.oracle.com; or post DDL to allow us to recreate the tables and indexes, and the SQL from your report.

  • MRP run - misalignment for planned order between Date and Production Date

    Hi All,
    We've just integrated SAP for a new plant.
    The MRP runs based on Routing Lead Time for Make materials instead on Material Master Lead Time, for Capacity Assessment purpose.
    When requirements dates lay in the past, MRP performs forward scheduling starting from current date and properly defines Production End Date according to Routing.
    By checking MD04, for the proposed Planned Order, the basic date is same as Current Date (= same as Requirement Date) instead of being same as Production Date.
    It works as it if checks stil the MAterial MAster LEad time instead of Routing. In fact if I updated the LT of MM the MD04 provides the right Date.
    For future requirements, the MRP works properly, by having basic dates (both start and end date) aligned with Production Dates of Planned Order.
    How can I do the alignment w/o updating In House Production LT?
    Thanks,
    D

    Hi Caetano,
    we have already done this configuration in OPU5 but it doesn't provide any benefit.
    Below how we configured it:
    Scheduling level: Via detailed scheduling
    Adjust dates: adjust basic dates, adjust dep. reqmts to operation date
    For capacity scheduling: Always basic dates, dep. reqmts to operation dates
    Scheduling type: Backwards.
    Regards,
    D.

  • Query for Business Partner  Master data

    Respected Sir/Madam,
                           I want a Query in Bp Master Data----> "Name" Should Allow Only Capital Letters.Can anyone please helpme out from this.

    Hi,
    Apply FMS to BP Name field.
    Set below query in FMS and tick auto refresh with "When Exiting Altered Column" and select field Quantity and select "Refresh Regularly" .
    Select UCASE($[OCRD.CardName)
    Regards,
    Clint

  • Query for months & quarter in date functions

    Hi All
    Could some on assist me how to get Last Year 1st,2nd,,, months and Current Year 1st,2nd,3rd,,, months and same way Quarterly please.
    I have date column Trade_date (dd/Mon/yyyy), Trade_price in Trade table
    DB:Oracle 11g
    Any assist would be appreciated

    All you have done is repeat your unclear question with more words.
    Here is how to get all the months for prior year and this year
    SQL> alter session set nls_date_format = 'Mon-YYYY';
    Session altered.
    SQL> select
      2      add_months(this_year, - 12) last_year,
      3      this_year
      4  from
      5      (
      6      select
      7          add_months(trunc(sysdate,'y'), level - 1)    this_year
      8      from
      9          dual
    10      connect by
    11          level <= 12
    12      );
    LAST_YEA THIS_YEA
    Jan-2010 Jan-2011
    Feb-2010 Feb-2011
    Mar-2010 Mar-2011
    Apr-2010 Apr-2011
    May-2010 May-2011
    Jun-2010 Jun-2011
    Jul-2010 Jul-2011
    Aug-2010 Aug-2011
    Sep-2010 Sep-2011
    Oct-2010 Oct-2011
    Nov-2010 Nov-2011
    Dec-2010 Dec-2011
    12 rows selected.And quarters
    SQL> select
      2      add_months(this_year, - 12) last_year,
      3      this_year
      4  from
      5      (
      6      select
      7          add_months(trunc(sysdate,'y'), (level - 1) * 3)    this_year
      8      from
      9          dual
    10      connect by
    11          level <= 4
    12      );
    LAST_YEA THIS_YEA
    Jan-2010 Jan-2011
    Apr-2010 Apr-2011
    Jul-2010 Jul-2011
    Oct-2010 Oct-2011
    SQL> alter session set nls_date_format = 'dd/mm/yyyy';
    Session altered.
    SQL> select
      2      add_months(this_year, - 12) last_year,
      3      this_year
      4  from
      5      (
      6      select
      7          add_months(trunc(sysdate,'y'), (level - 1) * 3)    this_year
      8      from
      9          dual
    10      connect by
    11          level <= 4
    12      );
    LAST_YEAR  THIS_YEAR
    01/01/2010 01/01/2011
    01/04/2010 01/04/2011
    01/07/2010 01/07/2011
    01/10/2010 01/10/2011As you can see from the second example, the display format of dates is controlled by the session,
    >
    he date column is trade_date (dd/mm/yyyy)
    >
    So this is still incorrect - if it is a date the format is not dd/mm/yyyy and, it is still not clear how this relates to your other questions.

  • Query for selecting distinct by date

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    I have a simple table that has an ID, Title, and Date.
    I need to select the most recent ID (without duplicates). I was looking at using a UNION but couldn't quite get it to work.
    P3XGL2FV96     Test 1     11-AUG-10 03.38.06.000000000 PM
    1VGJ74PSNW     Test 2     11-AUG-10 04.02.22.000000000 PM
    1VGJ74PSNW     Test 2     12-AUG-10 09.49.09.000000000 AM

    Hi,
    You could achieve it like this :
    CREATE TABLE MY_TABLE
    +(+
    ID       VARCHAR2(10),
    TITLE    VARCHAR2(10),
    MY_DATE TIMESTAMP
    +);+
    insert into my_table values ('P3XGL2FV96', 'Test 1', '11-AUG-10 03.38.06.000000000 PM');
    insert into my_table values ('1VGJ74PSNW', 'Test 2', '12-AUG-10 09.49.09.000000000 AM');
    insert into my_table values ('1VGJ74PSNW', 'Test 2', '11-AUG-10 04.02.22.000000000 PM');
    commit;
    SELECT id, title, my_date
    FROM (SELECT id,
    title,
    my_date,
    RANK () OVER (PARTITION BY id ORDER BY my_date DESC) rk
    FROM my_table)
    WHERE rk = 1;
    ID        |TITLE     |MY_DATE
    ----------|----------|---------------------------------------------------------------------------
    +1VGJ74PSNW|Test 2 |12-AUG-10 09.49.09.000000 AM+
    P3XGL2FV96|Test 1    |11-AUG-10 03.38.06.000000 PM
    Remark : if one id have twice the same date they will be both ranked first
    Kind regards,
    Ludovic
    Edited by: ludovic.sz on Aug 12, 2010 8:38 AM

  • Query for getting combination of data

    hi all,
    i am using db10g.
    i have a table of fields a_company,a_code,a_name,a_port,a_t_port,a_rate,a_volume
    i have a records like
    MM,AA,A-NAME,EFG,EFGH,100,20
    MM,AA,A-NAME,EFG,EFGH,200,10
    MM,BB,B-NAME,HIJ,HIJK,100,20
    MM,BB,B-NAME,HIJ,HIJK,200,30
    MM,CC,C-NAME,DEF,DEFG,500,20i have to select all columns but the fields if below below combination repeates(having more than 1 combination)
    a_company,a_code,a_port,a_t_port
    how can form a query?
    in other words i am expecting the result like below among above said input.
    MM,AA,A-NAME,EFG,EFGH,100,20
    MM,AA,A-NAME,EFG,EFGH,200,10
    MM,BB,B-NAME,HIJ,HIJK,100,20
    MM,BB,B-NAME,HIJ,HIJK,200,30Thanks..

    With only one table scan:
    SQL> create table a_table (a_company,a_code,a_name,a_port,a_t_port,a_rate,a_volume)
      2  as
      3  select 'MM','AA','A-NAME','EFG','EFGH',100,20 from dual union all
      4  select 'MM','AA','A-NAME','EFG','EFGH',200,10 from dual union all
      5  select 'MM','BB','B-NAME','HIJ','HIJK',100,20 from dual union all
      6  select 'MM','BB','B-NAME','HIJ','HIJK',200,30 from dual union all
      7  select 'MM','CC','C-NAME','DEF','DEFG',500,20 from dual
      8  /
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user,'a_table')
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> select a_company
      2       , a_code
      3       , a_name
      4       , a_port
      5       , a_t_port
      6       , a_rate
      7       , a_volume
      8    from ( select a.a_company
      9                , a.a_code
    10                , a.a_name
    11                , a.a_port
    12                , a.a_t_port
    13                , a.a_rate
    14                , a.a_volume
    15                , count(*) over (partition by a_company,a_code,a_port,a_t_port) cnt
    16             from a_table a
    17         )
    18   where cnt > 1
    19  /
    A_ A_ A_NAME A_P A_T_     A_RATE   A_VOLUME
    MM AA A-NAME EFG EFGH        100         20
    MM AA A-NAME EFG EFGH        200         10
    MM BB B-NAME HIJ HIJK        100         20
    MM BB B-NAME HIJ HIJK        200         30
    4 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=5 Bytes=330)
       1    0   VIEW (Cost=4 Card=5 Bytes=330)
       2    1     WINDOW (SORT) (Cost=4 Card=5 Bytes=140)
       3    2       TABLE ACCESS (FULL) OF 'A_TABLE' (Cost=2 Card=5 Bytes=140)Regards,
    Rob.

  • Query for spatial data with a GeometryCollection fails

    There are exact 538 CurvePolygons (only exterior rings at this
    sample). All of them are valid geometries and equal in dimension
    and so on. Now I connect them to a GeometryCollection and query
    for other relating spatial data in some tables. It seems that
    the use of around (not exact!) 200 CurvePolygon in one
    GeometryCollection works fine but the adding of more
    CurvePolygon result in an error with the Spatial Index (I could
    add the ORA- error numbers if I have some data in my test tables
    again next days).
    Is there anybody else having trouble with these mysterious
    problem? Maybe there is a border by the number of points in
    GeometryCollection?
    (More details, programming code could be delivered)
    (working with Java 1.3.1, oracle.sdoapi.*, Oracle 8.1.7.)

    Hi Lutz,
    Could you provide more info or samples of what is going wrong?
    Also, could you try making sure the geometry you are passing in
    as the query window is valid (i.e. instead of passing it in as a
    query window, pass it into sdo_geom.validate_geometry).
    Thanks,
    Dan

  • Query for select CLOB data field

    Hi All,
    I want to know how to write a SQL query for select CLOB tyoe data from a tablw. when I am trying to use the simple SQL it gives an messageLOB types requires OCI8 mode and currently uasing OCI7 ode.
    Also I am not aware of oci mode?
    If its working for OCI8 mode how I should changer it in to OCI8 mode? (I am using 10g rel 2)
    Thans and regards
    Buddhike

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • Run Query for Quarters

    I need query for Q1,Q2,Q3 data. Q is quarter.
    That is Q1=1 to 4
    Q2=4 to 8
    Q3=9 to 12
    I give above these parameters for this query.
    I select Q1 run this query. same run as Q2,Q3.
    (select d.valuedoc,
    (case when (d.el4='E9000') then 'Other Revenue' else '1' end ) as Line,
    h.yr,
    h.period
    from oas_dochead as h, oas_docline as d
    left outer join oas_grplist as g
    on d.el4=g.code and d.cmpcode=g.cmpcode and g.grpcode in ('21ONSITE', '21OFFSITE')
    where d.docnum=h.docnum
    and d.doccode=h.doccode
    and d.cmpcode=h.cmpcode
    and (h.yr between ?Year? - 3 and ?Year? and h.period between 1 and 4)
    )

    >
    I need query for Q1,Q2,Q3 data. Q is quarter.
    That is Q1=1 to 4
    Q2=4 to 8
    Q3=9 to 12Nope - they're not quarters - they're thirds.
    Quarters are 1-3, 4-6, 7-9, 10-12
    Kindly repost your query within
    .... tags - it's unreadable otherwise.
    Also, see my .sig for other information to post - DB version, OS
    &c.
    Paul...
    When asking database related questions, please give other posters
    some clues, like OS (with version), version of Oracle being used and DDL.
    Other trivia such as CPU, RAM + Disk configuration might also be useful.
    The exact text and/or number of error messages is useful (!= "it didn't work!"). Thanks.
    Furthermore, as a courtesy to those who spend time analysing and attempting to help,
    please do not top post and do try to trim your replies!

  • Ms access 2007 between query for date

    Dear All,
    I am using the below query to fetch records from a table between two dates
    select * from tablename where Format([VisitDate],"Short Date") >=Format(#01/10/2014#,"Short Date") and Format([VisitDate],"Short Date") <=Format(#31/10/2014#,"Short Date")
    I want records between 1st Oct to 31st Oct only, but the above query shows Nov and December data also. Please let me know where I am going wrong.
    Regards,
    Noor 
    Thanks & Regards, Noor Hussain

    The Format function returns a string expression, so the comparison is on that basis not on the date value.  You do not need to worry about the format at all as the date/time data type in Access is implemented as a 64 bit floating point number. 
    You can see it in whatever date/time format you wish, but the underlying value is always the same.  When you include a date literal in an SQL statement or in VBA code it must be either in US short date format (mm/dd/yyyy), or in an internationally unambiguous
    format.  The ISO standard format for date notation of YYYY-MM-DD is a good choice.  So you query would be:
    SELECT *
    FROM tablename
    WHERE VisitDate  >=  #2014-10-01#
    AND VisitDate < #2014-11-01#;
    Note that the range is defined as on or after the start date and before the day following the end date.  This ensures that all relevant rows are returned.  As there is no such thing in Access as a 'date value', but only a 'date/time value' it is possible
    that a 'date' of 31 October 2014 could have a non-zero time of day element unless you have taken steps in the table definition to specifically exclude values with a non-zero time of day.  Such date/time values would not fall within a range ending <=
    #2014-10-31#, so would not be returned by the query.  Defining the end of the range with < #2014-11-01# ensures that such rows are returned.
    Ken Sheridan, Stafford, England

Maybe you are looking for

  • Cannot install camera profiles in Raw 5.2

    After re-downloading Adobe Raw 5.2 and running the CameraProfiles.exe program and restarting my system I still cannot find any camera profiles under Camera Calibration other than the standard ones in either Lightroom or Camera Raw. I click the dropdo

  • TB Display

    My TB display flickered twice and died this morning, no reset button just ran out of warranty, any suggestions?

  • Embed an external view into a tabbed menu

    Hi All, I'm a beginner in WebDynpro Java. Could you please help me to embed an external view into a tabbed menu in WebDynpro Java? Please help with your solutions. Thank you. Regards, Sari

  • 10g AS Forms & Reports Services 10.1.2.0.2

    Hi, Can anyone PLEASE help me!!!!! I have just installed 10g AS Forms & Reports Services 10.1.2.0.2. I have got the forms to work without any problem. How on earth does the Reports Server start? I have read that it is an inprocess server in that when

  • Use of BPM Sub-Process

    Hello Experts, I'm beginner and I wanna know when we will go for BPM sub process. I know there are two types of process(embedded and reference), but I wanna know when we will go for embedded sub process and for reference sub process. If possible plea