Query using BETWEEN/AND operators

Im trying to query in forms using BETWEEN/AND operators. The field is for dates (YYYY) is stored in the DB as varchar (4). My code compiles but returns nothing...Any ideas of whats wrong...
PROCEDURE YR_RANGE_SEARCH IS
BEGIN
IF :SEARCH.NRA_START IS NOT NULL
AND :SEARCH.NRA_END IS NOT NULL THEN
:Global.BUFFER_START := :SEARCH.NRA_STRT;
:Global.BUFFER_END := :SEARCH.NRA_END;
BEGIN
SET_BLOCK_PROPERTY('NRHR', ONETIME_WHERE, 'NRHR.YEAR = ''' || 'BETWEEN' || :Global.BUFFER_START || 'AND' || :Global.BUFFER_END ||'''');
GO_BLOCK('NRHR');
EXECUTE_QUERY;
END;
END IF;
END;

check spaces in quoted text. i noticed that in your original query you had no spaces anywhere which made your ONETIME_WHERE resulting in something like NRHR.YEAR='BETWEEN2005AND2007' (if :Global.BUFFER_START=2005 and :Global.BUFFER_END=2007). For sure that always resulted in NULL value returned by the query;
in my answer
SET_BLOCK_PROPERTY('NRHR', ONETIME_WHERE, 'NRHR.YEAR BETWEEN '|| :Global.BUFFER_START || ' AND ' || :Global.BUFFER_END);
there is a space after BETWEEN and space before and after AND. Be careful.

Similar Messages

  • SAP QUERY using ASSHR and ASSOB tables

    We currently have SAP query that reports on additional payments (Info type 0015).  The user wants to report the cost center held on the cost assignment (Tables ASSOB and ASSHR).
    The existing query uses infoset created using PNP logical database. 
    How do I add or join the ASSOB and ASSHR tables to Info type 0015 to report the cost center?
    Thanks in advance
    Shamshudin

    Hi Sham
    You may need to create custom fields in the infoset and create some code to pull out and display details from ASSHR and ASSOB corresponding to the ifnotype record.

  • Difference between & and && operators in if.

    Hi,
    this question seems like silly, but I am confused when I used these two operators in "if "condition,
    is these 2 operators are act like same in if statement. like for example
    if( 10 == 10 & "a".equals("a")){
    System.out.print("true");
    if( 10 == 10 && "a".equals("a")){
    System.out.print("true");
    when I executed above statements both printing true.
    Can you please clarify on this.
    Thanks in advance

    Usually true, but not entirely accurate. the single & operator is also used for boolean And, but it does not short circuit the evel. try this code ofr a test
    String s = null;
         String l = "l";
         if(s == null && l.equals("l") )
             System.out.println("test 1");
         if(l.equals("a") && s.length() > 0)
             System.out.println("test 2");
         else
             System.out.println("Short circuited, l != a");
         try{
         if(l.equals("a") & s.length() > 0)
             System.out.println("test 3");
         catch (NullPointerException npe)
             System.out.println("Silly programmer, s is null");
         }~Tim

  • How to write a query use between two months

    Hello,
    I have two views v1 and v2. Both have two columns c1 and c2: c1 with mon-yyyy format, c2 is a number. I am writing a query like this;
    select v1.c2, v2.c2 from v1, v2
    where v1.c1 = v2.c1 and v1.c1 between to_date('Jan-2011','mon-yyyy')
    and to_date('Dec-2011','mon-yyyy')
    i got: ORA-01858: a non-numeric character was found where a numeric was expected
    V1 and V2 value are like these:
    Mon-2011 89
    Feb-2011 33
    Mar-2011 45
    Apr-2011 98
    How to make it work.
    Thanks for your help.
    Jen

    Hello Jen Hu,
    Try this:
    with t as ( select 'feb-2011' as c1, 33 as nr from dual union
    select 'mar-2011',45 from dual union
    select 'apr-2011',98 from dual union
    select 'jun-2011',86 from dual union
    select 'jul-2011',78 from dual union
    select 'aug-2011',87 from dual union
    select 'sep-2011',68 from dual union
    select 'oct-2011',56 from dual union
    select 'nov-2011',68 from dual union
    select 'dec-2011',55 from dual union
    select 'jan-2012',54 from dual
    ) SELECT * FROM T
    where to_date(c1,'mon-yyyy') between to_date('aug-2011','mon-yyyy') and to_date('dec-2011','mon-yyyy');@Tauceef:
    >
    Tauceef wrote:
    You have to store full date, the conversion you are doing to_date('jan-2011','mon-yyyy') is not at all accepted, this is where you are getting that error.
    >
    Why not? Have you tried:
    select to_date('jan-2011','mon-yyyy') from dual;Once you convert the character string into date it is easier to compare!
    I agree with @clcarter's point:
    >
    Firstly, if you want to compare dates, use a DATE datatype, not varchar2. If the varchar2 has invalid dates you'll have all sorts of trouble. 'Feb-31-2011' is a perfectly valid string. But its not a date.
    >
    But if you have better mechanism of valid string input as in here:
    http://apex-plugin.com/oracle-apex-plugins/item-plugin/month-picker_148.html
    then problems of invalid string input are minimized!
    Hope it helps!
    Regards,
    Kiran

  • Help with a query using ISNULL and RTRIM in the same select statement

    What I'm trying to accomplish is to blend the following two statements together:
    ISNULL (EMail_Address, '') As Matrix_Member_Email
     AND
    RTRIM (EMail_Address) as Matrix_Member_EMail
    So that if the email address is NULL, it gets changed to blank and I still need to RTRIM the other entries and use the column header of Matrix_Member_Email.
    I've tried:
    ISNULL ((EMail_Address, '') (RTRIM (EMail_Address)) as Matrix_Member_EMail
    Any help would be greatly appreciated.
    Thank you,

    I'm sorry.  Here is the query:
    --Declare @EMail_Address nvarchar(100) = null
    Select SVAssociationID.R_ShortValue as MATRIX_AssociationID, Matrix_Modified_DT as Matrix_LastModified
      ,RTRIM (MLS_ID) As Matrix_MLS_ID
      , ISNULL(EMail_Address, '') AS MATRIX_member_Email
      ,RTRIM (EMail_Address) as Matrix_Member_EMail
      --,RTRIM( LTRIM(  ISNULL (@EMail_Address, '') ) ) as Matrix_Member_EMail 
      ,Last_Name AS MATRIX_LastName, Nickname AS MATRIX_NickName
      FROM    dbo.Agent_Roster_VIEW a
            LEFT JOIN dbo.select_values_VIEW SV ON a.Status_SEARCH = SV.ID
            LEFT JOIN dbo.select_values_VIEW BillType ON a.Bill_Type_Code_SEARCH = BillType.ID
      LEFT JOIN dbo.select_values_VIEW SVAssociationID ON A.Primary_Association_SEARCH = SVAssociationID.ID
    WHERE   Status_SEARCH IN (66,68) 
        Order by MLS_ID
    Results:
    MATRIX_AssociationID
    Matrix_LastModified
    Matrix_MLS_ID
    MATRIX_member_Email
    Matrix_Member_EMail
    MATRIX_LastName
    MATRIX_NickName
    STC
    09/02/14
    CCWILLI
    [email protected]
    [email protected]
    Williams                      
    Christine   
    STC
    09/12/14
    CCWORSL
    [email protected]
    [email protected]
    Worsley                       
    Charlie
    STC
    09/02/14
    CCYROBIN
    NULL
    Robinson       
    ECBR
    09/02/14
    CDABLACK
    [email protected]
    [email protected]
    Black                         
    Dale        
    STC
    09/02/14
    CDABRADY
    [email protected]
    [email protected]
    Brady                         
    David       
    Thank you,

  • UPDATE SQL query using WHERE and a date/time data type... Multiple changes...

    I'm using the LabView Database Connectivity Toolset and am using the following query...
    UPDATE IndexStation
    SET Signal_Size=200
    WHERE 'StartTime=12:05:23'
    Now the problem is that this command seems to update all rows in the table IndexStation... Not just specifically the row where StartTime=12:05:23
    I have tries all sorts of {} [] / ' " around certain characters and column names but it always seems to update all rows...
    I've begun to use the SQL query tab in Access to try and narrow down as to why this happens, but no luck!
    Any ideas!?
    Thanks,
    Chris.

    Chris Walter wrote:
    I completely agree about the Microsoft issue.
    But it seems no SQL based manual states that { } will provide a Date/Time constant.
    Is this an NI only implementation? Because I can't seem to get it to function correctly within LabView or in any SQL query.
    Chris.
    There is nothing about the database toolkit in terms of SQL syntax that would be NI specific. The database Toolkit simply interfaces to MS ADO/DAO and the actual SQL syntax is usually implemented in the database driver or database itself although I wouldn't be surprised if ADO/DAO does at times munch a bit with that too.
    The Database Toolkit definitely does not. So this might be a documentation error indeed. My understanding of SQL syntax is in fact rather limited so not sure which databases might use what delimiters to format date/time values. I know that SQL Server is rather tricky thanks to MS catering for the local date/time format in all their tools and the so called universal date/time format has borked on me on several occasions.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Error executing a query using VPD and BC4J

    Hi all,
    Our team is developing an application using an Oracle DB 9.2.0.4 and BC4J 10g (9.0.5.16.0) as persistence layer.
    We also are using the VPD (virtual private database) to have security in the database at row level.
    The problem we are facing is that every some time (days) we get a jdbc error when a query (see below) that uses VPD policies is executed. Once the error occurs I execute it from sqlplus without getting any error .. it only occurs from our java application.
    To temporary solve this problem, we delete and recreate the VPD policies, then the application continue working fine for some time ...
    I'll appreciate any comment / suggestions
    Thank in advance.
    Eduardo.
    ERROR LOG:
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT CalLocation.ID,
    CalLocation.CODE, eo
    CalLocation.NAME,
    CalLocation.ZIP,
    CalLocation.PHONE,
    CalLocation.FAX,
    CalLocation.ADDRESS1,
    CalLocation.ADDRESS2,
    CalLocation.URL,
    CalLocation.OWNER,
    CalLocation.CTY_ID,
    CalLocation.DESCRIPTION,
    ORefCity.CODE CTY_CODE,
    ORefCountry.ID CTR_ID,
    ORefCountry.CODE CTR_CODE,
    ORefRegion.ID REG_ID,
    ORefRegion.CODE REG_CODE
    FROM CAL_LOCATIONS CalLocation,
    OREF_CITIES ORefCity,
    OREF_COUNTRIES ORefCountry,
    OREF_REGIONS ORefRegion
    WHERE ORefCity.ID = CalLocation.CTY_ID
    and ORefCountry.ID = ORefCity.CTR_ID
    and ORefRegion.ID = ORefCountry.REG_ID) QRSLT WHERE ( ( (CTY_ID = 867) ) )
    ## Detail 0 ##
    java.sql.SQLException: Io exception: Broken pipe
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:345)
         at oracle.jdbc.driver.OracleStatement.open(OracleStatement.java:717)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2605)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:457)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:387)

    The symptoms we have been getting are quite similar to the bug 3662364 .
    I'm going to implement the patch for that bug and see what happend then.
    Thank you very much for your help.
    Regards,
    Eduardo.

  • Query using Between for date range

    Hi,
    I need to list a date range of registration.. i entered
    4/12/2007 (as value for form.regstart) and 7/12/2007 (as value for
    form.regend)..
    WHERE dateregistered BETWEEN #CreateODBCDate(form.regstart)#
    AND #CreateODBCDate(form.regend)#
    the result that i got was only from 4/12/2007 to 6/7/2007..
    however when i run the same coding at mysql.. it works
    perfectly..
    any idea?

    Turn on debugging and see what dates show up in the sql that
    went to your db. Cold Fusion might be confused by your date format.
    I certainly am.

  • Help with supply and demand query using monthly buckets

    I'm working on a query bound for Discoverer which pulls the aggregated supply and demand for an item and buckets it into months. So for any given item, I need to show the item, onhand, cost, aggregated supply (planned orders, requisitions, pos), and aggregated demand (planned order demand, jobs) - all bucketed by months.
    The code below works okay to find all of the data for July, but I also need to show August and September. I'm thinking I could use a union but am reluctant because the query already runs kind of slow and I'm not sure if I'm on the right track.
    Database Server
    RDBMS : 10.2.0.3.0
    Oracle Applications : 11.5.9
    -Tracy
    select
          item.inventory_item_id, item.organization_code, item.item, item.description
        , item.make_buy,item.planner_code
        , planned.compile_designator, planned.order_type_text, sum(planned.quantity_rate)planned_total
        , planned.mrp_sugg_due_month
        , sum(job.required_quantity-job.quantity_issued)job_open, job.required_month
        , onhand.total_qoh
        , purchase.item_revision prev, purchase.promised_month, purchase.ship_to_organization_id 
        , sum((purchase.quantity-purchase.quantity_cancelled)-purchase.quantity_received)po_open  
        , req.item_revision rrev, req.destination_organization_id, req.org_id, req.need_by_month
        , sum((req.quantity-req.quantity_cancelled)-req.quantity_delivered)req_open
        , cost.item_cost,cost.cost
    from
    --item--
    (select mtl.inventory_item_id, mtl.segment1 item,mtl.description,decode(mtl.planning_make_buy_code,1,'Make',2,'Buy') make_buy
            ,mtl.organization_id, mtp.organization_code, mtl.planner_code
           ,to_char(add_months(sysdate,+1),'YYYY_MM')month1, to_char(add_months(sysdate,+2),'YYYY_MM')month2
           ,to_char(add_months(sysdate,+3),'YYYY_MM')month3
    from    inv.mtl_system_items_b mtl, inv.mtl_parameters mtp
    where    mtl.organization_id = mtp.organization_id
    )item,
    --planned orders - 3 months --
    (select compile_designator,organization_id,inventory_item_id,order_type_text,nvl(quantity_rate,0)quantity_rate,new_due_date
           ,to_char(trunc(new_due_date,'MM'),'YYYY_MM')mrp_sugg_due_month
    from   apps.mrp_orders_sc_v
    where  order_type_text in ('Planned order','Planned order demand')
    and    to_char(trunc(new_due_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(new_due_date,'MM'),'YYYY_MM') >=  to_char(:Month,'YYYY_MM')
    )planned,
    --jobs - 3 months--
    (select organization_id,wip_entity_name job, inventory_item_id,concatenated_segments,nvl(required_quantity,0)required_quantity
            ,nvl(quantity_issued,0)quantity_issued, date_required,to_char(trunc(date_required,'MM'),'YYYY_MM') required_month
            ,wip_entity_id,creation_date, wip_job_status
    from    apps.wip_requirement_ops_inq_v
    where   primary_item_id <>inventory_item_id
    and     wip_job_status not in ('Closed','Cancelled','Complete')
    and     to_char(trunc(date_required,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and     to_char(trunc(date_required,'MM'),'YYYY_MM') >= to_char(:Month,'YYYY_MM')
    )job,
    --qty onhand--
    (select  inventory_item_id,organization_id,sum(nvl(transaction_quantity,0))total_qoh
    from     inv.mtl_onhand_quantities_detail
    group by inventory_item_id, organization_id
    )onhand,
    -- po - 3 months--
    (select pol.item_id, pol.item_revision, nvl(pll.quantity,0)quantity, nvl(pll.quantity_received,0)quantity_received
          , nvl(pll.quantity_rejected,0),nvl(pll.quantity_cancelled,0)quantity_cancelled,poh.segment1 po_num
           ,pll.promised_date, to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')promised_month
           ,pll.shipment_num,pll.ship_to_organization_id 
    from   po.po_lines_all pol, po.po_headers_all poh, po.po_line_locations_all pll
    where  poh.po_header_id = pol.po_header_id
    and    pol.po_header_id = pll.po_header_id
    and    pol.po_line_id = pll.po_line_id
    and    pol.cancel_flag != 'Y'
    and    pol.item_id is not null
    and    to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')<= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')>=  to_char(:Month,'YYYY_MM')
    )purchase,
    --reqs - 3 months--
    (select prh.segment1 req_number,nvl(prl.quantity,0)quantity,nvl(prl.quantity_delivered,0)quantity_delivered
           ,nvl(prl.quantity_cancelled,0)quantity_cancelled
           ,prl.destination_organization_id,prl.org_id,prl.item_id,prl.item_revision,prl.need_by_date
           ,to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM')need_by_month
    from   po.po_requisition_headers_all prh, po.po_requisition_lines_all prl
    where  prh.requisition_header_id = prl.requisition_header_id(+)
    and    nvl(prl.cancel_flag,'N') !='Y'
    and    prh.authorization_status != 'CANCELLED'
    and    to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
    and    to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') >=  to_char(:Month,'YYYY_MM')
    )req,
    --cost--
    (select msib.inventory_item_id,msib.organization_id,cqm.material_cost,cic.item_cost
    ,(case when cqm.material_cost=0 then cic.item_cost else cqm.material_cost end) cost, cqm.cost_group_id
    from inv.mtl_system_items_b msib
         ,(select cql.cost_group_id,cql.inventory_item_id,cql.organization_id,cql.layer_quantity,cql.material_cost,mp.organization_code
             from bom.cst_quantity_layers cql, inv.mtl_parameters mp
            where mp.default_cost_group_id = cql.cost_group_id) cqm
        ,bom.cst_item_costs cic
    where msib.inventory_item_id = cqm.inventory_item_id(+)
    and msib.organization_id = cqm.organization_id(+)
    and msib.inventory_item_id = cic.inventory_item_id(+)
    and msib.organization_id = cic.organization_id(+)
    )cost
    where item.inventory_item_id = job.inventory_item_id(+)
    and   item.organization_id = job.organization_id(+)
    and   item.month1 = job.required_month(+)  -- 2009_07 --
    and   item.inventory_item_id = onhand.inventory_item_id(+)
    and   item.organization_id = onhand.organization_id(+)
    and   item.inventory_item_id = purchase.item_id(+)
    and   item.month1 = purchase.promised_month(+)  -- 2009_07 --
    and   item.inventory_item_id = req.item_id(+)
    and   item.month1 = req.need_by_month(+)  -- 2009_07 --
    and   item.inventory_item_id = cost.inventory_item_id(+)
    and   item.organization_id = cost.organization_id(+)
    and   item.inventory_item_id = planned.inventory_item_id(+)
    and   item.organization_id = planned.organization_id(+)
    and   item.month1 = planned.mrp_sugg_due_month(+)  -- 2009_07 --
    and   item.make_buy = 'Buy'
    and   item.item in ('161309040','744L755','150-GFM') --test items --
    group by item.inventory_item_id,item.organization_code,item.item,item.description,item.make_buy,item.planner_code
          ,job.required_month ,onhand.total_qoh , purchase.item_revision,  purchase.promised_month
            ,purchase.ship_to_organization_id  ,cost.item_cost,cost.cost
           ,req.item_revision, req.destination_organization_id,req.org_id,req.need_by_month
           ,planned.compile_designator,planned.order_type_text,planned.mrp_sugg_due_month
    order by item.organization_code,item.item

    Hi,
    Six things:
    (1) Where are the one-to-many relationships between your tables? If a single row in mtl can match two (or more) rows in mrp, and can also match two (or more) rows in wip, then it looks like, when you join both of them them, you'll have a chasm trap, that is, you'll get all the matching rows from mrp paired with all matching rows from wip. Are you sure your existing query is producing the right results?
    Are there one-to-many relationships with the other tables in your original query?
    (2) Are your DATEs always at midnight? If not, avoid using BETWEEN and LAST_DAY for DATE comparisons: otherwise you'll miss everything between 00:00:01 and 23:59:59 on the last day.
    That is, instead of
    and     mrp.new_due_date(+) BETWEEN :Month AND LAST_DAY(ADD_MONTHS(:Month,2))ypou should say
    and       mrp.new_due_date (+)     >= :Month
    and       mrp.new_due_date (+)     <  ADD_MONTHS (:Month, 3)(3) The basic way to pivot the months of mrp_due_date is:
    SELECT    ...
    ,       NVL ( SUM ( CASE
                     WHEN  mrp.new_due_date >= :month
                     AND   mrp.new_due_date < ADD_MONTHS (:month, 1)
                     THEN  mrp.quantity_rate
                    END
               , 0
               )          AS mrp_qty_0
    ,       NVL ( SUM ( CASE
                     WHEN  mrp.new_due_date >= ADD_MONTHS (:month, 1)
                     AND   mrp.new_due_date <  ADD_MONTHS (:month, 2)
                     THEN  mrp.quantity_rate
                    END
               , 0
               )          AS mrp_qty_1When you do this, do not GROUP BY TRUNC (mrp.new_due_date, 'MM').
    The code above does two months: I'm sure you get the idea for how to do more.
    To get dynamic column headings (such as Jun_2009 or "2009-06" instead of the generic mrp_qty_o) requires dynamic SQL. The best way to do dynamic SQL depends on the tool that is producing the query (e.g. SQL*Plus). What are you using? Are you willing to change, if it helps?
    (4) Displaying separate columns from one row as a single column on multiple rows is called unpivoting. How badly do you want to do that? Your query would be simpler and faster if the output had only one row per group (rather than one row for mrp_qty and another row for wip_wty). That one row could have six columns (e.q. June_mrp, June_wip, July_mrp, July_wip, August_mrp and August_wip) instead of three. Depending on your front-end tool, you might even be able to wrap the single row of output so that it always appeared as two rows, each with three columns.
    (5) Sorry I told you to do
    and     mrp.order_type_text(+) in (...)I never use the + outer-join notation any more, so I forgot about the ORA-01719 error. There's no problem having an outer-join condition like that using ANSI notation. (One more reason to switch.)
    (6) As you noticed, this site doesn't like to print the &lt;&gt; inequality operator, even inside tags.
    Use the equivalent != operator instead, when posting on this site.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Using multiple 'and' conditions in a SQL query

    Is it possible to reduce the SQL required to query using multiple 'and' conditions, e.g. I have a query like the following:
    select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
    from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
    where stat.apy_apn_id = apps.rgn_apt_id
    and apps.rgn_apt_id = appt.rgn_apt_id
    and stat.application_completed is null
    and stat.application_started_date > '01-MAY-11'
    and stat.amount_paid is null
    and stat.personal_details = 'C'
    and stat.further_details = 'C'
    and stat.education = 'C'
    and stat.employment = 'C'
    and stat.personal_statement = 'C'
    and stat.choices = 'C'
    and stat.reference = 'C'
    and stat.student_finance = 'C'
    Is there a way, to reduce all the multiple 'and' queries, to be read from say one line? If you know what I mean.......

    Ah, Ok this looks nice, thanks very much. It doesn't quite run as is because the stat.amount_paid query value is 'is null', while the others are 'C'. I tried amending the relevant line to various versions of the following:-
    in (select 'is null' 'C','C','C','C','C','C','C','C' from dual)
    which doesn't work.
    I can get the following to work so I am assuming that the it is not possible to use different query values within the brackets of the 'in (select....' statement?
    select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
    from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
    where stat.apy_apn_id = apps.rgn_apt_id
    and apps.rgn_apt_id = appt.rgn_apt_id
    and stat.application_completed is null
    and stat.application_started_date > '01-MAY-11'
    and stat.amount_paid is null
    and (stat.personal_details, stat.further_details, stat.education,
    stat.employment, stat.personal_statement, stat.choices, stat.reference, stat.student_finance)
    in (select 'C','C','C','C','C','C','C','C' from dual)
    Thanks for everybodys help - the suggested alternatives seem so much more elegant

  • Between and operator is not working

    Oracle 10g
    Hi
    SELECT to_char(reportingdatetime,'DD-MON-YYYY HH24:MI:SS'), code, description, details, processname, instanceid, order_number,upi,reference
    FROM XXHDNL_INT_HUB_ERROR_DETAILS
    where
    to_char(reportingdatetime,'DD-MON-YYYY HH24:MI:SS') between '30-NOV-2010 06:00:00' and '01-DEC-2010 05:59:59'
    and
    CODE ='2M-4103'
    I am using this query to get the error details but its not returning any row.
    But when ran the query without "between and" i am getting the output of 30 Nov and 01 Dec records
    Pls correct where i went wrong
    Thanks & Regards
    Srikkanth.M

    1) You have a data model error. Dates really really ought to be stored as a DATE or a TIMESTAMP. Storing date data as a VARCHAR2 is going to cause a whole raft of problems down the line.
    2) If ReportingDateTime is a VARCHAR2, it makes no sense to use TO_CHAR. It's already a string, no good can come from trying to convert it to a string. And you can introduce lots of fun bugs because the TO_CHAR call forces the string to be converted to a date using the session's NLS_DATE_FORMAT and then that date is converted back to a string. If the NLS_DATE_FORMAT for the session happens not to match the hard coded date format, you'll suddenly start getting errors.
    3) Your example works because '29-NOV' comes before '30-DEC' alphabetically. But you would also return data for '29-Oct' and '29-Sept' which is almost certainly not what you want.
    4) Until you correct the data model issue, you want
    WHERE to_date( ReportingDateTime, 'DD-MON-YYYY HH24:MI:SS' )
      BETWEEN to_date( '29-NOV-2010 06:00:00', 'DD-MON-YYYY HH24:MI:SS' )
          AND to_date( '30-DEC-2010 05:59:59', 'DD-MON-YYYY HH24:MI:SS' )5) If you are going to make the mistake of storing date date as a character string, it would make sense to at least choose a format that sorts the same alphabetically and chronologically (i.e. 'YYYYMMDDHH24MISS'). Not that this would make #1 any less true. But it would at least reduce the possibility that someone incorrectly doing a string comparison would at least get the right results.
    Justin

  • Problem with using between condition

    Hi all,
    In my query I need to pass two dates , so I'm using between/ and condition it suppose return 24 rows but it returning 48 rows. If I use single date then I'm getting result correctly ie. 24 rows. Pls help me correcting my query.
    SELECT sttl_item_nme
    || '|'
    || master_rpt_version_dt_sys
    || '|'
    || LTRIM
    (MAX (SYS_CONNECT_BY_PATH (sttl_item_amt, '|'))KEEP (DENSE_RANK LAST ORDER BY curr),
    '|'
    || '|'
    || SUM (sttl_item_amt)
    || '|' AS total
    FROM (SELECT a.sttl_item_nme, master_rpt_version_dt_sys,
    sttl_pub_cd,
    NVL (b.sttl_item_amt, 0) sttl_item_amt,
    ROW_NUMBER () OVER (PARTITION BY a.sttl_item_nme ORDER BY 1)
    AS curr,
    ROW_NUMBER () OVER (PARTITION BY a.sttl_item_nme ORDER BY 1)
    - 1 AS prev
    FROM nm_sttl_item_dtl_type a,
    nm_sttl_item_dtl b,
    nm_settlement c
    WHERE a.sttl_item_num = b.sttl_item_num
    AND b.sttl_id = c.sttl_id
    --and sttl_item_nme in ('FTR Transaction Amount','DA Asset Energy Amount')
    AND c.sttl_pub_cd = 'S14'
    AND c.ptcpt_cd = 'DEMO'
    --AND c.sttl_type_cd IN ('RTSTTL', 'DASTTL')
    AND c.master_rpt_version_dt_sys between '04/17/2005' and '04/20/2005')
    --AND c.master_rpt_version_dt_sys ='04/18/2005')
    GROUP BY sttl_item_nme, master_rpt_version_dt_sys, sttl_pub_cd
    CONNECT BY prev = PRIOR curr AND sttl_item_nme = PRIOR sttl_item_nme
    START WITH curr = 1
    ORDER BY master_rpt_version_dt_sys, sttl_pub_cd DESC,
    sttl_item_nme
    Thanks & Regards,
    Ramana.

    Hi Ghulam,
    Using to_char function doesn't solve my problem . What actual the query is doing ,when I took multiple dates its concatenating the data from other dates along with the first date also.
    The actual data for individual date is
    18 th data
    DA Loss Rebate on Carve-out GFA|04/18/2005|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|
    19th data
    DA Loss Rebate on Carve-out GFA|04/19/2005|-370.6|-350.2|-353.6|-357|-380.8|-244.8|-207.5|-257.5|-260|-265|-265|-265|-257.5|-250|-217.5|-207.5|-195|-182.5|-187.5|-545|-580|-205|0|-200.6|-6605.1|
    20th data
    DA Loss Rebate on Carve-out GFA|04/20/2005|-448.8|-428.4|-414.8|-442|-472.6|-635.8|0|0|-207.5|-222.5|-222.5|-222.5|-212.5|-212.5|-195|-190|0|0|-170|-495|-535|-345|0|-190.4|-6262.8|
    when I used between '04/18/2005' and '04/20/2005' condition the result is
    18thdata
    DA Loss Rebate on Carve-out GFA|04/18/2005|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|
    19th data
    DA Loss Rebate on Carve-out GFA|04/19/2005|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|-448.8|-428.4|-414.8|-442|-472.6|-635.8|0|0|-207.5|-222.5|-222.5|-222.5|-212.5|-212.5|-195|-190|0|0|-170|-495|-535|-345|0|-190.4|-370.6|-350.2|-353.6|-357|-380.8|-244.8|-207.5|-257.5|-260|-265|-265|-265|-257.5|-250|-217.5|-207.5|-195|-182.5|-187.5|-545|-580|-205|0|-200.6|-6605.1|
    20th data
    DA Loss Rebate on Carve-out GFA|04/20/2005|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|-448.8|-428.4|-414.8|-442|-472.6|-635.8|0|0|-207.5|-222.5|-222.5|-222.5|-212.5|-212.5|-195|-190|0|0|-170|-495|-535|-345|0|-190.4|-6262.8|
    Still I am unable to figure out how to resolve this.Pls help me out from this problem. Your help is greatly appreciated.
    Thanks & Regards,
    ramana.

  • Query using Infoset (NW04s)

    I have an infoset based on a CUBE & DSO. I create a query on Infoset. The query uses 0GL_ACCOUNT and uses a hierarchy. In the query result, there are instances where the a G/L account amount does not roll up to the associated hierarchy node.
    Example
    GL Node 1 -
    $0.00
    GL Acct----
    $500.00
    I don't get this problem when I run a similar query on CUBE.

    Hi Rajesh,
    There will be two querry areas, check in which area you have created Infoset and user group. You will find the combination in relevant query area only.
    Two area are
    Standard Area (Client-specific)
    Global Area (Cross-client)
    Thanks
    ANAND K

  • What table does BI query use?

    hi all,
    i'm new to BI. how i know the table the BI query uses? and one more question, can i review the abap code of the BI query?
    thanks in advance for your effort.
    Peerasit

    Hi,
    the query is created on a specific provider. Each provider consists of a bunch of tables --> fact tables, dimension tables. Additionally the sid and master data tables of the characteristics are used for reporting, but that depends pretty much on your query definition.
    For the code, goto transaction rsrt, enter the name of the query and click on the button technical information. In the upcoming list you will find the name of the generated program.
    regards
    Siggi

  • Difference between - and = in OOABAP?

    Hi all,
       I want to know the use of => and -> Operators in OOPs.
    Thanks,
    Suresh

    Hi Suresh,
    The -> operator is used to access instance attributes and methods of a class
    The => operator is used to access static attributes  and methods of a class.
    The static attributes  & methods can be directly accessed as class_name=>attribute or class_name=>method( ).
    The instance attributes & methods can be accessed only via object references of classes like, oref->attribute, oref->method( ).
    Hope it helps,
    Regards, Sudeep..

Maybe you are looking for

  • Cannot connect to DB from remote computer (ORA-12545)

    Hello all, Please help, I am stumped.  I am trying to connect to a database located at my work from at home. I am running into the following issue (see command and error below): ansichart@ansivm:~/src/perl$ sqlplus aspxdba/********@aspxp2 SQL*Plus: R

  • Oracle VM 3.1.1, Oracle VM Server, PeopleSoft Templates and networking

    I have installed Oracle VM Manager on an Oracle Linux x86_64 system, all freshly installed, and two Oracle VM Server 6 systems also freshly installed. These three servers are each connected to two networks. One is a 192.168.15.0/24 ("net-A"), and the

  • Portions of email is garbled

    This mostly happens with Safari, but here's an example of an email I received from a local radio station. For the most part it's clear enough, but this section is a prime example of how the text can go wacky. Kansas City Chiefs will be featured in th

  • Cannot insert object error in excel

    Team, While I'm trying to insert a pdf file in excel getting error like "cannot insert object"... Steps which i tried : 1. re installed the adobe reader 2. checked with AdbeRdr11004 and AdbeRdr11009 both the versions its working at the time of instal

  • Block Diagram Error

    I'm getting an error when i try to connect two sub-vi's. Error: The type of the source is 1-D array of double. The type of the sink is 1-D array of waveform. Does someone know. I'm using LV6i. Iwert