Simple query help in plsql - help

oracle version : 10gR2
indexes are created on each column, is there anyway to make them used while searching for the records rewriting the following query to test given data in any case (lower ,upper)...
SELECT * FROM TX_USERS
WHERE userid like decode( UPPER('Md'),null,userid, UPPER( 'MD')||'%' ) and
first_name like decode(UPPER('Na'),null, first_name, UPPER( 'NA')||'%' ) AND
LAST_name like decode(('Ra'),null, LAST_name, UPPER('RA')||'%' )
-- list goes on..
UPPER('Md') -- is the input values comes from form.. for example i_userid.. this query works fine .. is there anyway of getting indices used without using functional based indexing when we rewrite query like shown below??? input parameter valeus can be anything and table column values can be anything i.e. anycase (upper or lower or mix of both)..
actual code would be
upper(userid) like decode( UPPER(i_userid),null,userid, UPPER( i_userid)||'%' ) and
upper(first_name) like decode(UPPER(i_first_name),null, first_name, UPPER( i_firstname)||'%' )
if we put upper(userid) then index not used ..........anyway of rewriting using it or any other technique... or any other new way

No, its not working... see the below..
create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
but when i use
select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
.. any help...
not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
requirements is
mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx

Similar Messages

  • Looks like a simple query but need your help

    Hello everyone,
    I have a simple problem but I can't get over it. Actually, it looks like a simple problem, but I can't do it. So,it's probably not... Anyone can help me with this?
    Imagine the following data:
    ALTER SESSION SET NLS_DATE_FORMAT = 'DD/MM/YYYY HH24:MI:SS';
    SELECT TRUNC(SYSDATE) - TO_DATE('01/01/11', 'DD/MM/RR') FROM dual; -- 564
    DROP TABLE runs;
    CREATE TABLE runs
      start_date DATE,
      end_date DATE
    -- generate some random data
    INSERT INTO runs(start_date)
      SELECT TO_DATE('01/01/11', 'DD/MM/RR') + trunc(dbms_random.value(0,564))
        FROM dual
    CONNECT BY LEVEL <= 10000;
    -- still generating sample data
    UPDATE runs
       SET end_date = start_date + dbms_random.value(0,20000) / 86400; -- 20000 sec is the max
    COMMIT; If you execute the previous "script", you'll end up with a table called RUNS with 10.000 records. Each record contains a start date and an end date which is max 20.000 second after the start date.
    What I would like to do is a report based on these data.
    I need something like this:
    (first week of 2011 started on sunday. So I go back to the last monday of 2010)
    WEEK_NUMBER                              AVG_FOR_MONDAY_BY_WEEK  CUMULATIVE_AVERAGE_FOR_MONDAYS
    Week 1: 26/12/2010 - 01/01/2011                                       9999                           88888
    Week 2: 02/01/2011 - 08/01/2011                                       1111                           22222
    ....For each week, I would like to have the average duration (which is the difference in seconds between end_date and start_date) by day (monday needs to have its average, tuesday, wednesday...too)
    And I also need a cumulative average by week and by days (mondays, tuesdays...). This cumulative average needs to be based on all the preceding rows.
    Can anyone help me with this query? I'm using Oracle 10g
    Thanks

    Hi,
    Something along these lines :
    alter session set nls_date_language = "english";
    with all_data as (
      select to_char(start_date, 'IYYYIW') as wk
           , to_char(start_date, 'dy') as dy
           , (end_date - start_date)*86400 as duration
      from runs
    week_data as (
      select wk
           , round(avg(case when dy = 'mon' then duration end)) as avg_mon
           , round(avg(case when dy = 'tue' then duration end)) as avg_tue
           , round(avg(case when dy = 'wed' then duration end)) as avg_wed
           , round(avg(case when dy = 'thu' then duration end)) as avg_thu
           , round(avg(case when dy = 'fri' then duration end)) as avg_fri
           , round(avg(case when dy = 'sat' then duration end)) as avg_sat
           , round(avg(case when dy = 'sun' then duration end)) as avg_sun
      from all_data
      group by wk
    select wk
         , avg_mon
         , sum(avg_mon) over(order by wk) as cum_avg_mon
         , avg_tue
         , sum(avg_tue) over(order by wk) as cum_avg_tue
         , avg_wed
         , sum(avg_wed) over(order by wk) as cum_avg_wed
         , avg_thu
         , sum(avg_thu) over(order by wk) as cum_avg_thu
    from week_data
    order by wk;
    WK        AVG_MON CUM_AVG_MON    AVG_TUE CUM_AVG_TUE    AVG_WED CUM_AVG_WED    AVG_THU CUM_AVG_THU
    201052                                                                                
    201101       9836        9836       8737        8737       9088        9088      12167       12167
    201102       7639       17475      10319       19056       7391       16479       8036       20203
    201103       8275       25750       8883       27939       8525       25004      11682       31885
    201104       7029       32779      10850       38789       7360       32364       7617       39502
    201105      10292       43071      11421       50210      11141       43505       9469       48971
    201106      11612       54683       9762       59972      11464       54969       9517       58488
    201107       8645       63328      10206       70178      10124       65093      11917       70405
    201108      11466       74794      11678       81856      10839       75932       9587       79992
    201109       8745       83539       6803       88659       8963       84895       9496       89488
    201110      10443       93982       8104       96763      10314       95209      10908      100396
    201111       8183      102165       9467      106230      11495      106704      12040      112436
    201112       8575      110740       9207      115437      10338      117042       9561      121997
    201113      10273      121013       6268      121705      11288      128330      12335      134332
    201114      10176      131189       8561      130266      10367      138697       7983      142315
    201115      10587      141776      12073      142339       8528      147225      12271      154586
    201116       9393      151169      10761      153100       7901      155126      10020      164606
    201117      11459      162628       9471      162571      10136      165262       8188      172794
    201118      11946      174574       9997      172568       9367      174629      10475      183269
    201119      12869      187443       9848      182416       7692      182321       9632      192901
    201120       9675      197118       7408      189824      11646      193967       9614      202515
    201121      10742      207860      10302      200126       9208      203175       7543      210058
    201122       8083      215943       8323      208449      10045      213220       9498      219556
    201123      11838      227781       8820      217269       8804      222024      10485      230041
    201124       8748      236529      12143      229412       9684      231708       8402      238443
    201125      11504      248033      10586      239998      10073      241781       9573      248016
    201126       7289      255322      14241      254239      10100      251881      11843      259859
    201127      10855      266177       9980      264219      10320      262201      11023      270882
    201128      11004      277181       9975      274194      11609      273810       8945      279827
    201129      10488      287669       9402      283596      11985      285795       9481      289308
    201130       7338      295007       8963      292559      11982      297777       8177      297485
    201131       9778      304785      10024      302583      10732      308509      10749      308234
    201132      10360      315145      12577      315160       8643      317152      10001      318235
    201133       9845      324990      10416      325576       9996      327148      10548      328783
    201134       9540      334530       8138      333714       9401      336549       9093      337876
    201135       7000      341530       9920      343634      10370      346919      10937      348813
    201136      11307      352837       8889      352523      12339      359258       8491      357304
    201137      11785      364622       9146      361669       9232      368490      11023      368327
    201138       7857      372479       6784      368453       8502      376992      12558      380885
    201139       9842      382321      10616      379069      10435      387427       7848      388733
    201140      10578      392899       9402      388471       8806      396233       9927      398660
    201141       6711      399610      13015      401486       9934      406167      10011      408671
    201142      10088      409698      10380      411866       7836      414003       9205      417876
    201143       8132      417830      11772      423638      10792      424795      10834      428710
    201144       9921      427751       7454      431092       9551      434346      10754      439464
    201145      13196      440947      11600      442692      11303      445649      10455      449919
    201146      12022      452969       8996      451688      10221      455870      12567      462486
    201147       8965      461934      10068      461756      10607      466477      13486      475972
    201148       9483      471417       9264      471020       9601      476078       8685      484657
    201149      11738      483155       9000      480020      10284      486362      11263      495920
    201150      10338      493493      10237      490257      10357      496719      10984      506904
    201151      10777      504270      11138      501395      10543      507262       9840      516744
    201152       9881      514151      10692      512087      11432      518694      10122      526866
    201201      11089      525240       8077      520164      12391      531085       9649      536515
    201202       9871      535111       8326      528490       9449      540534      10551      547066
    201203      10625      545736      11609      540099       9626      550160       5795      552861
    201204       8856      554592       9679      549778      10722      560882      11064      563925
    201205       9379      563971       9943      559721       8409      569291      11656      575581
    201206      10843      574814      10070      569791      12162      581453      10764      586345
    201207       8424      583238       8484      578275       8382      589835       8716      595061
    201208      11159      594397      10415      588690      11459      601294      11317      606378
    201209      11264      605661       8244      596934       9682      610976      10192      616570
    201210      11514      617175       9322      606256       9101      620077      10571      627141
    201211       9348      626523       7501      613757      12297      632374      11170      638311
    201212      10523      637046       7605      621362      10348      642722      10068      648379
    201213      10411      647457      11686      633048      10212      652934       9574      657953
    201214       9394      656851      10526      643574       8521      661455       9829      667782
    201215       8994      665845      12256      655830       8243      669698      10592      678374
    201216      11491      677336      10939      666769      12846      682544       9708      688082
    201217       9737      687073       9611      676380       7244      689788      10943      699025
    201218       9024      696097      11286      687666      10033      699821      10314      709339
    201219       9851      705948       9851      697517       9159      708980       9917      719256
    201220       7785      713733      10490      708007       8534      717514       8528      727784
    201221      11107      724840       8197      716204       8926      726440      10834      738618
    201222       8093      732933      11853      728057      11697      738137      10081      748699
    201223       9371      742304      10796      738853      11068      749205       9904      758603
    201224      10600      752904       8487      747340      10838      760043       8009      766612
    201225      11090      763994       9595      756935      10736      770779       9387      775999
    201226       8234      772228      12759      769694       9119      779898       8422      784421
    201227       9738      781966       9383      779077       8978      788876      11635      796056
    201228      11687      793653      10302      789379       9459      798335      10608      806664
    201229       9245      802898      11290      800669                 798335                 806664
    82 rows selected

  • Help with a simple query

    Hi ,
    I'm running the following simple query in sql*plus on ORACLE9i. But this query stopped running after 30minutes, and the sql*plus die at the same time .I have no idea about this. Could somebody tell me how I can solve this problem. Thank you very much for your help.
    Select Distinct PERSADDRUSE. ADDRUSECD as "Application", PERS.PERSNBR as "Account",
    (PERS.FIRSTNAME || ' '|| PERS.MDLINIT ||' ' || PERS.LASTNAME ) as "Name1",' 'as "Name2",' 'as "Name3",
    AL1.TEXT as "Address1",AL2.TEXT as "Address2",AL3.TEXT as "Address3",
    (ADDR.CITYNAME ||' ' || ' '||ADDR.STATECD ||' '||ADDR.ZIPCD||' '|| ADDR.ZIPSUF) as "CityStateZip"
    From PERSADDRUSE
    Join PERS
    ON PERS.PERSNBR = PERSADDRUSE.PERSNBR
    --AND  PERS.ADDDATE = '12-JAN-2005'
    AND PERSADDRUSE.ADDRUSECD = 'PRI'
    join ADDR
    ON PERSADDRUSE.ADDRNBR = ADDR.ADDRNBR
    left JOIN ADDRLINE AL1
    ON ADDR.ADDRNBR = AL1.ADDRNBR
    AND AL1.LINENBR = 1
    left JOIN ADDRLINE AL2
    ON ADDR.ADDRNBR = AL2.ADDRNBR
    AND AL2.LINENBR = 2
    left JOIN ADDRLINE AL3
    ON ADDR.ADDRNBR = AL3.ADDRNBR
    AND AL3.LINENBR = 3;

    Thanks for reply. I have some other query running for 45m and it seems fine. The following are the explain plan I print out. I'm new to PL/SQL.Could you guys give me some other ideas?
    BMS_XPLAN.DISPLAY()(PLAN_TABLE_OUTPUT)
    PERSADDRUSE | 5726 | 68712 | 183 |'), DBMS_XPLAN_TYPE('| 8 | TABLE ACCESS FULL| PERS | 161K| 2839K| 431 |'), DBMS_XPLAN_TYPE('| 9 | TABLE ACCESS FULL | ADDR | 239K| 5145K| 298 |'), DBMS_XPLAN_TYPE('| 10 | TABLE ACCESS FULL | ADDRLINE | 82087 | 1683K| 240 |'), DBMS_XPLAN_TYPE('| 11 | TABLE ACCESS FULL | ADDRLINE | 82087 | 1683K| 240 |'), DBMS_XPLAN_TYPE('| 12 | TABLE ACCESS FULL | ADDRLINE | 82087 | 1683K| 240 |'), DBMS_XPLAN_TYPE('------------------------------------------------------------------------'), DBMS_XPLAN_TYPE(' '), DBMS_XPLAN_TYPE('Note: cpu costing is off, PLAN_TABLE'' is old version'))

  • Help! no response when doing SIMPLE query!

    I meet a strange problem when I do a SIMPLE query on a table in Oracle 8.1.7, just like:
    SELECT id FROM person WHERE id='12345';
    Most of id values are ok to the query, except some values.
    Whether I use these values in sqlplus or JDBC, mostly, no response is returned!! And I find the session in Oracle always keeps the status 'Active'. But in few scenario I can get the result quickly.
    I don't know the reason. Help me please!
    Thanks a lot!
    Meyor

    I'm not sure if the 'id' column contains something else.
    When I shutdown and restart the database, the problem seems to be "solved". If the problem reoccurs again, I will try to use xTRIM functions.
    Thanks!
    Meyor

  • HELP on simple query

    I am trying to run kodo under Tomcat. In order for the user to login I do a simple query:
    PersistenceManager pm = pmf.getPersistenceManager ();
    KodoQuery q = (KodoQuery) pm.newQuery (UserInfo.class, "username == u_name && password == p_word");
    q.setUnique(true);
    q.declareParameters("String u_name, String p_word");
    UserInfo u = (UserInfo) q.execute(u_name, p_word);
    pm.close ();
    if (u == null)
    return (0);
    else
    return (1);
    I get the following exception:
    Unable to execute a query on type "class com.login.UserInfo". This class or interface is not persistent, and does not have any persistent implementors.
    I can run a JDOQL query using the same class from the kodoworkbench and it works fine. What am I missing?

    I am trying to run kodo under Tomcat. In order for the user to login I do a simple query:
    PersistenceManager pm = pmf.getPersistenceManager ();
    KodoQuery q = (KodoQuery) pm.newQuery (UserInfo.class, "username == u_name && password == p_word");
    q.setUnique(true);
    q.declareParameters("String u_name, String p_word");
    UserInfo u = (UserInfo) q.execute(u_name, p_word);
    pm.close ();
    if (u == null)
    return (0);
    else
    return (1);
    I get the following exception:
    Unable to execute a query on type "class com.login.UserInfo". This class or interface is not persistent, and does not have any persistent implementors.
    I can run a JDOQL query using the same class from the kodoworkbench and it works fine. What am I missing?

  • How do tune sql query? Can somebody help me in this? Atleast prescribe book

    how do tune sql query? Can somebody help me in this? Atleast prescribe a reference book.
    I am not able understand How to analyze tkproof output.

    Check out asktom.oracle.com
    Lot's of threads on interpreting tkprof output - no simple easy solution here.
    You need to understand what is happening and THINK. Then you can be a good engineer.
    As for good books...
    Tom Kyte's books are really, really good.
    http://www.amazon.com/Effective-Oracle-Design-Osborne-ORACLE/dp/0072230657/ref=sr_1_3?ie=UTF8&s=books&qid=1266783471&sr=8-3
    http://www.amazon.com/Expert-Oracle-Database-Architecture-Programming/dp/1590595300/ref=sr_1_1?ie=UTF8&s=books&qid=1266783471&sr=8-1
    Good luck!

  • SAP query transport error - need help

    hello,
      The system is throwing the following error when importing the query from development to QA client.
    We already have the query imported the first time without errors. This is happening with subsequent transports if there is a change or any modification to the query.
    Below is the error log from SAP regarding the failed transport :
    R3TRAQQUFI was repaired in this system
    Message no. TW104
    Diagnosis
    Object R3TRAQQUFI is in repair status. Therefore, it cannot be imported.
    System Response
    The object is not imported.
    Procedure
    If you still want to import the object, release the relevant repair and repeat the import.
    Please help
    Thanks in advance.

    Hi
    Here I am sending the step by step procedure for the SAP Query. Hope this helps you, if so please issue points.
    1. Go to SQ02 .
    Select Environment -> Query Areas
    Select Standard Area (Client specific) as show below
    2. Select Environment -> Transports
    Select Import radio button
    Check Overwriting allowed (only with import/upload/copy)
    Remove Check for Test Run
    Select Transport InfoSets and queries radio button
    Fill Infoset and Query with corresponding names
    Fill Import option with transport request number.
    3.  Click on Execute button
    With this it will be done.
    Thanks for your patience

  • Input ready query input help problem (F4 help)

    Dear All,
    We are using NW2004s with SP9.
    We have created an aggregation level with 0MAT_SALES, 0SALESORG, 0DISTR_CHAN (0SALESORG and 0DISTR_CHAN are compound characteristics of 0MAT_SALES) characteristics (and other char. as well). We have a Filter where we added the above mentioned characteristics and a navigational attribute of 0MAT_SALES (0MAT_SALES_NAV_ATT)
    We set the follwing filter values:
    0SALESORG = AT01
    0DISTR_CHAN = 01
    0MAT_SALES_NAV_ATT = P
    0MAT_SALES = nothing but we set the 'Can be changed at execution' flag in the modeler.
    We have an input ready query on the above mentioned aggregation level. We are using 0MAT_SALES as free characteristic and we set 'Only posted values' on the extended tab.
    Our 1. problem is that when we want to enter new rows into the Query and get input help (F4 on the input ready cell) to select 0MAT_SALES we get all 0MAT_SALES values and <u>not</u> only that ones which has 0SALESORG and 0DISTR_CHAN values set in the filter.
    Our 2. problem is that 0MAT_SALES_NAV_ATT = P is not taken into consideration during query execution and we also get all materials.
    Any help?
    Thanks in Advance,
    Dezso

    Dezso,
    We looked into using Navigational Attributes in SP7 and found that Input Queries were unable to process them. Unless there has been some specific enhancements I do not believe that anything has changed here.
    I recommend raising an OSS and getting clarification from Waldorf. The SAP Help page on input queries in IP also provides some clarification in this respect.
    Hope this helps.

  • Simple Query in Oracle Linked Table in MS Access causes full table scan.

    I am running a very simple query in MS ACCESS to a linked Oracle table as follows:
    Select *
    From EXPRESS_SERVICE_EVENTS --(the linked table name refers to EXPRESS.SERVICE_EVENTS)
    Where performed > MyDate()
    or
    Select *
    From EXPRESS_SERVICE_EVENTS --(the linked table name refers to EXPRESS.SERVICE_EVENTS)
    Where performed > [Forms]![MyForm]![Date1]
    We have over 50 machines and this query runs fine on over half of these, using an Oracle Index on the "performed" field. Running exactly the same thing on the other machines causes a full table scan, therefore ignoring the Index (all machines access the same Access DB).
    Strangely, if we write the query as follows:
    Select *
    From EXPRESS_SERVICE_EVENTS
    Where performed > #09/04/2009 08:00#
    it works fast everywhere!
    Any help on this 'phenominon' would be appreciated.
    Things we've done:
    Checked regional settings, ODBC driver settings, MS Access settings (as in Tools->Options), we have the latest XP and Office service packs, and re-linked all Access Tables on both the slow and fast machines independantly).

    Primarily, thanks gdarling for your reply. This solved our problem.
    Just a small note to those who may be using this thread.
    Although this might not be the reason, my PC had Oracle 9iR2 installed with Administratiev Tools, where user machines had the same thing installed but using Runtime Installation. For some reason, my PC did not have 'bind date' etc. as an option in the workarounds, but user machines did have this workaround option. Strangely, although I did not have the option, my (ODBC) query was running as expected, but user queries were not.
    When we set the workaround checkbox accordingly, the queries then run as expected (fast).
    Once again,
    Thanks

  • A simple query to show sales versus last year on daily basis/

    Hi guys,
    I want to build a simple query with day (1,2,3,4,5,6) on the rows and "sales current year" and "sales last year"
    on the columns.
    I have only 0CALDAY in my cube.
    How can I have on the rows the day in stead of the full date?
    I would like to see in the sames row sales current year and sales last year.
    Thanks
    Shlomi

    HI Shlomi
    Create a virtual characteristic in your infoprovider that can calculate the day from calendar Day. In ZXRSRZZZ while adding code for this virtual characteristic use the function module DATE_COMPUTE_DAY to compute the day for every calendar day.
    For calculating Sales Current year, create a restricted ky figure with Sales as the key figure. Add 0CalDay to this RKF and create a variable for this infoobject(Eg: ZCURYEAR) that will receive input from the user for the range of dates eg: 08/16/2009 - 08/22/2009.
    For Sales Prior year, create another restricted key figure with Sales. Add 0CalDay to this RKF and add a customer exit variable. In the Customer exit code use the ZCURYEAR variable and offset it to prior year in both the upper and lower limits. This should work.
    I hope this helps.
    Thanks.

  • How I can delete a row using a simple query?

    SZSLIFE_SPRIDEN_PIDM     SZSLIFE_SGBSTDN_TERM_CODE_EFF     SZSLIFE_SLRRASG_BLDG_CODE     SZSLIFE_SLRRASG_ROOM_NUMBER     SZSLIFE_SLRRASG_BEGIN_DATE     SZSLIFE_SLRRASG_END_DATE
    48547     199890                    
    48547     199990                    
    48547     199990     BLU     205     09/03/1999     12/23/1999
    48547     200010                    
    48547     200010     BLU     205     01/25/2000     05/25/2000
    48547     200090                    
    48547     200090     MOR     406     09/03/2000     12/23/2000
    48547     200110                    
    48547     200110     MOR     406     01/25/2001     05/25/2001
    48547     200190                    
    48547     200210                    
    48547     200290                    
    48547     200310                    
    48547     200390                    
    48547     200410                    
    48547     200610                    
    Here is what a simple question is probably for some of you; I can not get this to work. I need to delete all the rows that are duplicate like row #2 with the same SZSLIFE_SGBSTDN_TERM_CODE_EFF but with not
    SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER     
    I need to write a code where it counts the SZSLIFE_SGBSTDN_TERM_CODE_EFF and if it have the same (2 times.
    I need to delete the row without SZSLIFE_SLRRASG_BLDG_CODE and SZSLIFE_SLRRASG_ROOM_NUMBER
    The SZSLIFE_SLRRASG_BLDG_CODE NEEDS to be not null, because I do an insert in this table I need to be able to insert null values.
    How I can use a simple query where I can delete all the duplicate records without bldg_code and room number…
    Here is the table description
    SZSLIFE_SPRIDEN_PIDM NUMBER(8)
    SZSLIFE_SPRIDEN_ID VARCHAR2(10)
    SZSLIFE_SPRIDEN_LAST_NAME VARCHAR2(60)
    SZSLIFE_SPRIDEN_FIRST_NAME VARCHAR2(60)
    SZSLIFE_SPRIDEN_MI VARCHAR2(15)
    SZSLIFE_SGBSTDN_TERM_CODE_EFF VARCHAR2(6)
    SZSLIFE_SGBSTDN_STST_CODE VARCHAR2(2)
    SZSLIFE_STVSTST_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_STYP_CODE VARCHAR2(2)
    SZSLIFE_STVSTYP_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_LEVL_CODE VARCHAR2(2)
    SZSLIFE_STVLEVL_DESC VARCHAR2(30)
    SZSLIFE_SGBSTDN_RESD_CODE VARCHAR2(10)
    SZSLIFE_STVRESD_DESC VARCHAR2(40)
    SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
    SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
    SZSLIFE_SLRRASG_BEGIN_DATE VARCHAR2(12)
    SZSLIFE_SLRRASG_END_DATE VARCHAR2(12)
    SLRRASG_ASCD_CODE VARCHAR2(2)
    I will appreciate any help!
    SLRRASG_ROLL_IND VARCHAR2(2)

    Thank you very much Sandeep, this works!
    1 DELETE SZSLIFE_TEMP2
    2 WHERE
    3 SZSLIFE_SGBSTDN_TERM_CODE_EFF
    4 IN
    5 (SELECT SZSLIFE_SGBSTDN_TERM_CODE_EFF
    6 FROM SZSLIFE_TEMP2
    7 GROUP BY
    8 SZSLIFE_SGBSTDN_TERM_CODE_EFF
    9 HAVING COUNT(*) > 1)
    10 AND
    11* SZSLIFE_SLRRASG_BLDG_CODE = ' '
    12 /
    4 rows deleted.
    The only thing here is that the SZSLIFE_SLRRASG_BLDG_CODE can not be defined as a a NULL, so I can not use
    where SZSLIFE_SLRRASG_BLDG_CODE is null
    Here is how those two columns are define:
    SZSLIFE_SLRRASG_BLDG_CODE VARCHAR2(10)
    SZSLIFE_SLRRASG_ROOM_NUMBER VARCHAR2(10)
    So,
    my question is it will be safe to do SZSLIFE_SLRRASG_BLDG_CODE = ' ' ?
    Again, it works, it deleted the rfows that I wanted...
    Thank you very much!!!
    Rogelio

  • Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.

    consider this situation,
     Two or more productid will be accquired by same customerid, by same shipvia, on the same  day of the week of shipped date. i want the simple query for this.
    my tables are  from northwind:
    [orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
    [orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
    i tried some but it is not exact, it gives wrong result.
    select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
    select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
    from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
    having count(od.ProductID) >1) pd
    join
    (select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
    group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
    on sd.CustomerID=pd.CustomerID

    Hi,
    I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
    tables for your review.
    In my example I have included:
    1. A customer which has purchased the same product on the same day, using the same ship 3 times,
    2. Another example the same as the first but the third purchase was on a different day
    3. Another example the same as the first but the third purchase was a different product
    4. Another example the same as the first but the third purchase was using a different "ShipVia".
    You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
    Please let me know if I have missed any requirements.
    Hope this helps:
    CREATE TABLE #ORDERS
     OrderID INT,
     CustomerID INT,
     OrderDate DATETIME,
     ShipVia VARCHAR(5)
    CREATE TABLE #ORDERS_DETAILS
     OrderID INT,
     ProductID INT,
    INSERT INTO #ORDERS
    VALUES
    (1, 1, GETDATE(), 'ABC'),
    (2, 1, GETDATE(), 'ABC'),
    (3, 1, GETDATE(), 'ABC'),
    (4, 2, GETDATE() - 4, 'DEF'),
    (5, 2, GETDATE() - 4, 'DEF'),
    (6, 2, GETDATE() - 5, 'DEF'),
    (7, 3, GETDATE() - 10, 'GHI'),
    (8, 3, GETDATE() - 10, 'GHI'),
    (9, 3, GETDATE() - 10, 'GHI'),
    (10, 4, GETDATE() - 10, 'JKL'),
    (11, 4, GETDATE() - 10, 'JKL'),
    (12, 4, GETDATE() - 10, 'MNO')
    INSERT INTO #ORDERS_DETAILS
    VALUES
    (1, 1),
    (2, 1),
    (3, 1),
    (4, 2),
    (5, 2),
    (6, 2),
    (7, 3),
    (8, 3),
    (9, 4),
    (10, 5),
    (11, 5),
    (12, 5)
    SELECT * FROM #ORDERS
    SELECT * FROM #ORDERS_DETAILS
    SELECT
     O.CustomerID,
     OD.ProductID,
     O.ShipVia,
     COUNT(O.ShipVia),
     DATENAME(DW, O.OrderDate) AS [Shipped Day]
    FROM #ORDERS O
    JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
    GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
    DROP TABLE #ORDERS
    DROP TABLE #ORDERS_DETAILS

  • SSAS source Query, Simple Query with never ending refresh time.

    Hello...
    A very simple query based on SSAS cube do not give answer. :-(
    I start a trace to see the exact mdx statement transmited to SSAS, run it in a query editor, the result is... immediate !
    Is there any clue to explain such a behavior ? cube meta data definition ?
    Any help is welcome
    ===========
    Version: 2.21.3974.242

    hello,
    find below the capture of the trace, cannot see any references to rowsets either cellsets...
    thank you for your help
    select{[Measures].[Fact Count]}on 0,nonempty(crossjoin([Invoice Attributes].[Scenario].[Scenario].allmembers,[Period Date].[Month].[Month].allmembers,[Period Date].[Quarter].[Quarter].allmembers,[Period Date].[Year].[Year].allmembers,[Product Line Techno].[Product
    Line Code].[Product Line Code].allmembers),{[Measures].[Fact Count]})properties member_caption,member_unique_name on 1 from(select([Invoice Attributes].[Scenario].&[ACTUALS],[Period Date].[Month].&[20150101],[Product Line Techno].[Product Line Code].&[EB])on
    0 from [Revenue Detailed])cell properties value
    <PropertyList xmlns="urn:schemas-microsoft-com:xml-analysis">
              <Catalog>OLAP12</Catalog>
              <SspropInitAppName>Microsoft SQL Server Management Studio - Query</SspropInitAppName>
              <LocaleIdentifier>1036</LocaleIdentifier>
              <ClientProcessID>5992</ClientProcessID>
              <Format>Native</Format>
              <AxisFormat>TupleFormat</AxisFormat>
              <Content>SchemaData</Content>
              <Timeout>0</Timeout>
              <DbpropMsmdActivityID>284bd120-34f1-4fac-83cb-e8cf443261ad</DbpropMsmdActivityID>
              <DbpropMsmdRequestID>f11764e9-b092-41ea-aae6-a91763960eae</DbpropMsmdRequestID>
            </PropertyList>

  • Trouble with a simple Query

    Hello, I'll start by saying that I am a noob. Anyways, I am trying to do what I thought would be a simple query to get records that are greater than or equal to the current date: this is my query...
    <cfquery name="getUpcoming" datasource="events">
    SELECT title, eventDate FROM event WHERE eventDate >= #Now()# ORDER BY eventDate ASC
    </cfquery>
    It works, sort of, I do get records that are greater than the current date, but any records that are equal to do not show up.
    I am assuming that it is looking at time as well, or I am doing it completely wrong. I don't know? Any help would be greatly appreciated.

    I didn't use the cfqueryparam as suggested, is there something dangerous about doing it this way?
    Nothing dangerous, no.  Just "less than ideal" (in a sloppy / lazy sort of way).  As I suggested, one should not hard-code dynamic values into the SQL string, one should pass them as parameters.  it's just "the way it should be done".
    When the DB receives your SQL string (with the dynamic values hard-coded), the DB engine needs to compile the SQL to make an execution plan before executing the query.  Any change to the SQL string requires recompilation.  However if you pass your parameter as parameters, then the SQL does not need to be recompiled.
    It's the same sort of thing as not using global variables unless one has to, despite the fact they're "easier", or duplicating code instead of refactoring code.  One should try to write decent code.
    Adam

  • Simple query builder

    Hi,
    I'm looking for simple query builder for free using, which is helper for any user, who no experiences with SQL (knows it a little). RDBMS is Oracle 8.0.6
    Regards
    Krzysztof Malinowski

    Hi,
    you may use the Oracle Query Builder for such purposes. The Query Builder is a component of the Oracle 6i Forms Developer Suite, which is downloadable here at OTN. The new Oracle 9i Developer Suite DOES NOT contain this product.
    Greetings
    Werner

Maybe you are looking for

  • MS Access and Sun Java Studio Creator

    I am new to the forum. Having searched for the issue above I failed to find a way to connect between MS Access database and Creator. However I came accross a thread in 2004 which suggested that Sun techs are working on a solution. I wonder if such a

  • SOAP and Java within an Application Package

    We are doing an integration with Oracle Content Server. We have successfully checked in reports by sending a SOAP with attachments message in the application package PSRF_REPORT_CREATE calling custom Java methods. All is well, until we try and receiv

  • Computer not recognizing iPod  touch

    This is the second time I've run into this problem. I have a 2nd generation iPod touch 16GB. I've had it for about three months so it's relatively new. I'm trying to connect it to my mac and when I plug it in, my touch will turn on and show that it's

  • How to read input from handheld scanner on a keyboard port

    Hi everybody, i have an application that should read input from a scanner. If i use a jTextField to input scanned data it works fine. the problem is that i don't want to use any text component to input data into it. And if i set the jtextField not vi

  • Someone family with JDom please come in!

    setDocType() doesn't work! The result file hasn't any doctype! Code like below: JDOMSource source = new JDOMSource(new Document(root).setDocType(docType)); StreamResult result = new StreamResult(file); TransformerFactory.newInstance().newTransformer(