SQL novice looking for a little help

A little SQL help asked for…because my solution works but runs like a pig.
I have two tables with a link many-many association table between them with two FK's defined on the PK's in the tables either side of the join.
CREATE TABLE TABLE1
ID VARCHAR2(20 BYTE) NOT NULL
, NAME VARCHAR2(20 BYTE)
, AGE NUMBER
, ADDR1 VARCHAR2(20 BYTE)
, CONSTRAINT TABLE1_PK PRIMARY KEY
ID
ENABLE
CREATE TABLE TABLE2
ID2 VARCHAR2(20 BYTE) NOT NULL
, TYPE VARCHAR2(20 BYTE)
, DATE_CREATED DATE
, CONSTRAINT TABLE2_PK PRIMARY KEY
ID2
ENABLE
CREATE TABLE LINK_TABLE
ID VARCHAR2(20 BYTE) NOT NULL
, ID2 VARCHAR2(20 BYTE) NOT NULL
, CONSTRAINT LINK_TABLE_PK PRIMARY KEY
ID
, ID2
ENABLE
ALTER TABLE LINK_TABLE
ADD CONSTRAINT LINK_TABLE1_FK1 FOREIGN KEY
ID
REFERENCES TABLE1
ID
ENABLE;
ALTER TABLE LINK_TABLE
ADD CONSTRAINT LINK_TABLE2_FK2 FOREIGN KEY
ID2
REFERENCES TABLE2
ID2
ENABLE;
Populated with the simple data set below that also establishes the many to many links between table1 and table2.
Insert into TABLE1 (ID,NAME,AGE,ADDR1) values ('a','jake',23,'london');
Insert into TABLE1 (ID,NAME,AGE,ADDR1) values ('d','jimmy',26,'lamelane');
Insert into TABLE1 (ID,NAME,AGE,ADDR1) values ('b','jenny',55,'lakeside');
Insert into TABLE1 (ID,NAME,AGE,ADDR1) values ('c','jemima',21,'lothian');
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('z','type1',to_date('10-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('x','type1',to_date('09-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('n','type2',to_date('04-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('d','type1',to_date('03-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('e','type1',to_date('03-MAR-13','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('f','type2',to_date('16-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('s','type4',to_date('04-MAR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('w','type3',to_date('05-APR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('h','type1',to_date('02-APR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('v','type2',to_date('23-APR-12','DD-MON-RR'));
Insert into TABLE2 (ID2,TYPE,DATE_CREATED) values ('k','type3',to_date('30-MAR-12','DD-MON-RR'));
REM INSERTING into LINK_TABLE
SET DEFINE OFF;
Insert into LINK_TABLE (ID,ID2) values ('a','z');
Insert into LINK_TABLE (ID,ID2) values ('a','x');
Insert into LINK_TABLE (ID,ID2) values ('a','f');
Insert into LINK_TABLE (ID,ID2) values ('d','d');
Insert into LINK_TABLE (ID,ID2) values ('d','e');
Insert into LINK_TABLE (ID,ID2) values ('b','w');
Insert into LINK_TABLE (ID,ID2) values ('b','x');
Insert into LINK_TABLE (ID,ID2) values ('b','v');
Insert into LINK_TABLE (ID,ID2) values ('a','n');
Insert into LINK_TABLE (ID,ID2) values ('c','s');
Insert into LINK_TABLE (ID,ID2) values ('c','k');
Insert into LINK_TABLE (ID,ID2) values ('a','s');
Insert into LINK_TABLE (ID,ID2) values ('a','v');
And thus when queried using the join, gives me this data.
select t1.*, t2.* from table1 t1, link_table lt, table2 t2
where lt.id = t1.id
and t2.id2 = lt.id2;
ID NAME AGE ADDR1 ID2 TYPE DATE_CREATED
a jake 23 london f type2 16-MAR-12
a jake 23 london n type2 04-MAR-12
a jake 23 london s type4 04-MAR-12
a jake 23 london v type2 23-APR-12
a jake 23 london x type1 09-MAR-12
a jake 23 london z type1 10-MAR-12
b jenny 55 lakeside v type2 23-APR-12
b jenny 55 lakeside w type3 05-APR-12
b jenny 55 lakeside x type1 09-MAR-12
c jemima 21 lothian k type3 30-MAR-12
c jemima 21 lothian s type4 04-MAR-12
d jimmy 26 lamelane d type1 03-MAR-12
d jimmy 26 lamelane d type1 03-MAR-13
12 rows selected
However, what I need is
for every unique ID in table1, I need the maximum date for in table2 but given that there needs to be a precedence on types in a predefined order, that order being
type4 trumps type2 which trumps type3 which trumps type1.
therefore the query I'm looking for will return the type, type4 and it's max date even if other types exist. If no type4's exist for a link from table1.id in table2 then return type2 and it's max date and so forth.
essentially my query should return
ID     TYPE     MAX_DATE_CREATED
a     type4     04-MAR-12
b     type2     23-APR-12 (since it has no type4 and type2 trumps the other)
c     type4     04-MAR-12
d     type1     03-MAR-13 (the highest precedence is type1 and it's highest date is 03-MAR-13)
Hmmm
I have achieved this using some odd SQL where I use CASE to score the type against the precedence and then sum the total in an aggregate super query but as I say, it runs like a pig, my real dataset is much bigger than this. Hope there's a nice chap/lady out there who rises to this challenge.
TIA
Jenny.

Hi, Jenny,
Welcome to the forum!
Here's one way:
WITH   got_r_num   AS
     SELECT t1.*
     ,      t2.*
     ,      ROW_NUMBER () OVER ( PARTITION BY  t1.id
                                    ORDER BY         CASE    t2.type
                                          WHEN  'type4'  THEN  1
                                          WHEN  'type2'  THEN  2
                                          WHEN  'type3'  THEN  3
                                          WHEN  'type1'  THEN  4
                                      END
                        ,            t2.date_created     DESC
                      )      AS r_num
     FROM   table1          t1
     ,      link_table      lt
     ,      table2          t2
     WHERE  lt.id      = t1.id
     AND    t2.id2      = lt.id2
SELECT     *     -- or whatever columns you want
FROM     got_r_num
WHERE     r_num     = 1
;This is an example of a Top-N Query , where we pick N items (N=1 in this case) from the top of an ordered list (or lists; in this case, we need a separate list for each id.) The analytic ROW_NUMBER function can assign numbers 1, 2, 3, ..., in order, with a separate set of numbers for each id. The tricky part in this problem is getting your trumping order. I used a CASE expresion to map each of the types to a number that reflected the order.
Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful!
Would you like to be even more helpful? Post your best attempt at a query. Even if it performs really poorly, it can help illustrate what you need to do, and maybe give ideas about how to do it. It could be that a small change in what you already have is all that's needed.
The query above will work in Oracle 9.1 or higher. It never hurts to say which version of Oracle you have.

Similar Messages

  • Young CC user looking for a little help

    Hi. I am a student user of many of Adobe's products, and I recently began using the Creative Cloud service, which is currently £15 a month here in Britain but will be hiked to £22.50 a month next year. Since I don't really work much yet (I do a few design/film jobs here and there), the whole thing feels a bit expensive. I do graphic design, photography, film-making and a little bit of web design, which is obviously a lot! Moreover, I am really frustrated with the recent hacks, and as a result I have been consolidating my future with the software. Since the web side of Adobe is neither too unique nor essential, I do not feel so bad losing them. However, programs like Photoshop and After Effects are really irreplaceable, so I am considering purchasing the Production Premium CS6 package for Mac on a student discount, which is around £470 on the Adobe website as an alternative to continuing next year with CC. I own a Mac and a Windows-based laptop, and obviously CC suits this better. All in all, this is a bit of a dilemma, and I'm struggling to come up with a resolution. Does anyone know somewhere I can get the Production Premium cheaper, will I still be able to buy CS6 in June when my year's worth of promotional CC runs out, could I face compatibility issues and, of course, does anyone have any suggestions? All help would be greatly appreciated- thank you!

    To all,
    Here are links to the
    Oracle® Healthcare Transaction Base
    Implementation Guide - 2003
    http://download.oracle.com/docs/cd/B12190_11/current/acrobat/ctb11ig.pdf
    Oracle® Healthcare Transaction Base
    Implementation Guide - 2004
    http://download.oracle.com/docs/cd/B15436_01/current/acrobat/ctb115ig.pdf

  • I have acquired windows office 2011 for my macbook but unable to open it. There are currently 3 files in the folder, 1 of which seems to be the actual program which is a hfs file. iv tried looking for programs to help me open it but failed

    i have acquired windows office 2011 for my macbook but unable to open it. There are currently 3 files in the folder, 1 of which seems to be the actual program which is a hfs file. iv tried looking for programs to help me open it but failed.
    when double clicking on the image it says unable to open and gives me the option to search the app store.
    any help would be much appreciated
    Adam

    Well, first, just make sure it's the Mac version and not the Windows version (which indeed would not run on your Mac). You say "Windows Office" which is why I mention it. I think you probably just mean "Microsoft Office" though.
    Next, is this on a disk (DVD), or did you purchase and download it from the Microsoft site?
    Matt

  • Looking for friends to help me get over a breakup

    PSN  MAGIIK-STICKZ  Hello All, This is very embarrassing and quite silly that I have to do this really. It's scary that I have to turn to the Internet to look for friends to help me in this time of need. In the beginning of the month my girl friend left me, we was together for 4 years, we had our ups and downs but we always remained strong. She told me she wanted to be with me forever and I wanted the same. I've only just turned 19 so this was my first relationship. Don't want to get into too much details why she left me, but I will tell you that she has already moved on after only leaving me for a month. The pain hurts so much and I'm trying to move on because I can't... Because I have no friends... I mean I have friends but they're definitely not the ones you can count on in this situation. They're more "Gym Bros" I believe if I can find people to group with, play games with, literally just talk to that would be amazing for me. I just needs things to take my mind off of her and I believe talking to new people will do that. We don't even have to play games, I'm very open to you just in-boxing me on PlayStation to socialize.  I'm opened to both males and females but if there are any females you would be helping a lot! I cut off all female ties for her for 4 years and now I have no female acquaintances so It would be nice to get experience talking to other females again just to boost my confidence back.  I understand what I am asking for might sound like a lot, and I definitely understand how needy I sound, but this was my last resort of trying to get over her as quickly as I can. I've been in a really really REALLY Dark Place for the past month and I can't take it anymore.  My psn/PS4 is MAGIIK-STICKZ  Inbox me and I will be forever grateful ! 

    rancidpunk wrote:
    Shuffles slowly away, no, no, no me and Mrs Rancid haven't been engaged for more than ten years without tying the knot, no, no, no, honest. Hey at least you got engaged, that took me ten years (dont let Sooz know)  Friends I can't help you with bud As for the forum and PS , as Sooz said there's here, and you might want to try some of the events http://community.eu.playstation.com/t5/Events/bd-p/bEN_CommunityEvents There's some good eggs around those folk that'll have you chatting rubbish on the mic within minutes  Heart breaks do indeed sux. Even some of the really short relationships can break your heart (I know one of my short ones did, proper knocked me about that one. Although now I see it as a positive turnaround in my life)  Hope one of us tools here will some how give you some cheer. Have a man hug   Oh ow, and just in case there's always the Cat Threadhttp://community.eu.playstation.com/t5/PlayStation-Off-Topic/Cat-Thread/m-p/15658225/highlight/true#M1060419 or Dogshttp://community.eu.playstation.com/t5/PlayStation-Off-Topic/The-Dog-Thread/td-p/16511247/highlight/true Although they get pretty deep in there. And the thought of being a lonely old man with lots of cats and a brown setee scares me way more  

  • SQL SCRIPT LOOKING FOR PAPERCLIP HELP

    Good morning,
    Please I need hel I am looking for this famous paperclip  I have choosed each Icon and I cant find it
    Thank you
    Microsoft SQL Server Management Studio:<o:p></o:p>
    1. Right-click the paperclip icon to the left to open the Table_Size.txt script or save<o:p></o:p>
    the script to your hard disk. You’ll use this script to identify the largest table by<o:p></o:p>
    size in kilobytes in a Microsoft Database.<o:p></o:p>

    Then why do you ask strangers rather than your "consultant"?  And this question sounds much like your previous one
    how to get table size

  • Looking for suggestion/idea/help WITH T-SQL

    Hi all,
    The scenario I have is a person can have one or more charges on his/her case. 
    One charge could be adjudicated as GUILTY and the other charge
    is DROPPED.  If this is the scenario, I would like to assign GUILTY Adjudication to this case.
    OR
    One charge could be WITHHELD and the other charge is DROPPED. 
    If this is the scenario, I would like to assign WITHHELD to this case.
    Under Adjudication column, I would like to see GUILTY for case number 12345 and WITHHELD for case 98765
    Sample data:
    Case Number                Charge                       Charge
                            Adjudication
    Disposition
    ==========           ======                    ===========         
    ============
    12345                        DUI                            
    GUILTY
    12345                        Driving w/o license       DROPPED
    98765                        DUI                            
    WITHHELD  
    98765                        Driving w/o license       DROPPED
    Below is the query that returned the above sample Charge Disposition.  I am thinking of using CASE expression to determine Adjudication but not sure.
    Thank you for everyone's help!
    declare @Begindate datetime--
    declare @Enddate datetime
    set @begindate = '05/01/2014'
    set @Enddate = '05/31/2014'
    SELECT
    (CASE
    WHEN cc1.ProsecutorFinalAction IN ('L','O','R') AND
    (cc1.ProsecutorFinalDecisionDate >= @BeginDate) AND
    (cc1.ProsecutorFinalDecisionDate < DateAdd(d, 1, @EndDate))
    THEN pfa1.Description
    WHEN (cc1.CourtDecisionDate >= @BeginDate)AND
    (cc1.CourtDecisionDate < DateAdd(d, 1, @EndDate))
    THEN dbo.fnGetLookupDescription(cc1.CourtActionTaken,'CourtActionTaken')
    END)
    FROM tblCase c1 with(nolock)
    INNER JOIN tblCaseCharge cc1 with(nolock)
    ON c1.caseid = cc1.caseid
    LEFT OUTER JOIN tblProsecutorFinalAction pfa1 WITH(NOLOCK)
    ON cc1.ProsecutorFinalAction = pfa1.ProsecutorCode
    WHERE c1.CaseID = @CaseID

    If you want to return just one row for each case, then:
    ;with cte as (SELECT *, ROW_NUMBER() over (PARTITION BY case_number
    ORDER BY case [Charge Disposition] WHEN 'GUILTY' then 1 WHEN 'WITHHELD' ELSE 3 END) AS RN
    FROM CasesInfo)
    SELECT * FROM cte WHERE Rn = 1 -- will select rows with GUILTY status or WITHHELD status
    and not dropped status
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Looking for trouble shooting help -Connections being dropped from app.

    I need a little help in hunting down the source of a problem. We have Oracle 10gR2 (10.2.0.1) running on Solaris 10. The web application is based on WEBLOGIC on another server also running Solaris 10 with a new firewall in between. When started, the application will get 176 connections to the database. Over time, still working on how long, the connections get dropped. The profile they app is connecting to is for unlimited connections and connection time. I do not have an setting to disconnect after idle for x minutes. Even the listener spawned processes die. Other applications from other machines also have problems if idle for a period of time, SQLDeveloper, SQLPlus, TOAD, SQLNAVIGATOR.
    We are trying to hunt down the source of the problem but are at a loss. I have checked and verified that the oracle instance does not have a parameter set to kill idle connections for the users the apps are connecting as. The sys admin says there are no unix parameters he knows about on either solaris box that is killing connections and that the firewall settings should not be killing them.
    A duplicate environment running all the same versions of software work fine, the only differences between the two is the box and operating system, Sun V120 w/Solaris 8 vs. Sun V40Z w/Solaris 10.
    This system goes live in two weeks so we are trying to get this figured out soon. Any hints on where to look or has any one else had similar problems?
    thanks

    listener.ora on Oracle server machine:
    # listener.ora Network Configuration File: /u01/app/oracle/product/10.2/db_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = /u01/app/oracle/product/10.2/db_1)
    (PROGRAM = extproc)
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ng-db01)(PORT = 1521))
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    Weblogic machine is not useing a client so has no sqlnet.ora file on it. Others having problem:
    # sqlnet.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.
    # This file is actually generated by netca. But if customers choose to
    # install "Software Only", this file wont exist and without the native
    # authentication, they will not be able to connect to the database on NT.
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

  • Looking for a little more info on Playstation 3 on Apple 20" display

    Sorry to ask for more info on this. I did find some other threads, but looking for a bit more direction.
    First, let me say I have a bunch of old tube TV's and am looking to purchase a Playstation 3. Using Playstation 3 on a tube TV seems kind of stupid, especially when I have a great LCD monitor sitting right on my desktop.
    I looked at solution from Elgato. However they said they are not making any more units and when it sells out it is gone. So I am a little weary of purchasing something that may no longer be supported. Their solution does provide video capture and DVR capabilities as well, which I could also use.
    Other then that, I am wondering if there are any other solutions that people could recommend. I do plan on buying a LCD or Plasma TV in the near future, but until then, I would like to purchase a Playstation 3. Just looking for any advice of any kind from others. Thanks.

    I have the same 20 inch Apple Display. If you have the newer DVI right?
    if so HDMI to DVI will not work well EyeTV from Elgato is still in the Mac store near me I have the 200 FireWire you want the 250 USB2 to do live. I have had the 200 FW for three years it is great.
    Having said that I did buy The Mitsubishi LCD LT-46231 : 46"
    1080p LCD Flat Panel HDTV ($4,600)
    I love it for computer use it was made for it. The HDTV is so good with cable and better with Blue-Ray which your PS3 has!
    http://www.mitsubishi-tv.com/j/i/18326/TelevisionDetails/LT46231.html?cid=377
    I would if you don't want to spend allot on a 1080p LCD (being more then 2k) The Mitsubishi LT-37131 LCD Flat Panel HDTV ($1,699) . Sony & Samsung both are the same LCD. Mitsubishi is better then Samsung/Sony allot better when used with a computer (it is the only new LCD maker that has a VGA & DVI port just for Computers)
    Both of the Mitsubishi Link's you will like as one is a money saver.
    http://www.mitsubishi-tv.com/j/i/18326/LT37131.html?cid=390
    http://www.mitsubishi-tv.com/j/i/18310/Promotions.html
    I also got a Pioneer Elite® Model PRO-FHD1 for TV only I will not run XBox or My computer though it. The link below show's why I got this to my mother need a new TV to so see the link 2 for 1
    http://www.pioneerelectronics.com/pna/v3/pg/top/cat/article/0,,2076310069651396920404,00.html
    Sorry to go on I hope it help's
    Thomas
    PowerMac G5 Quad 2.5Ghz, Dule2.0 G5, Mac Pro 3Ghz 6GB's PowerBook G4 12in 1.5Ghz   Mac OS X (10.4.8)   PowerMac G4 duel 1.25Ghz, iSight, iPod5, AppleDisplays 3 23in DVI GeForce 6800GT
    PowerMac G5 Quad 2.5Ghz, Dule2.0 G5, Mac Pro 3Ghz 6GB's PowerBook G4 12in 1.5Ghz   Mac OS X (10.4.8)   PowerMac G4 duel 1.25Ghz, iSight, iPod5, AppleDisplays 3 23in DVI GeForce 6800GT
    PowerMac G5 Quad 2.5Ghz, Dule2.0 G5, Mac Pro 3Ghz 6GB's PowerBook G4 12in 1.5Ghz   Mac OS X (10.4.8)   PowerMac G4 duel 1.25Ghz, iSight, iPod5, AppleDisplays 3 23in DVI GeForce 6800GT

  • Ran msconfig, but not sure what to look for... help?

    i ran msconfig and this is what is under my startup tab... can someone please help me understand what this means and what i should be looking for?
    These items are checked:
    real sched
    tgcmd
    qttask
    iTunesHelper
    ypwoa
    msmsgs
    MySpaceIM
    poxq
    these items are not checked:
    aim
    Ati2mdxx
    atiptaxx
    carpserv
    cpqset
    hptasks
    nvojln
    iTunesHelper
    dumprep 0 -k
    medgs1
    navapw32
    opr
    PCCClient
    pccguide
    Pop3trap
    setup
    PSof1
    OneTouch
    qttask
    REGSHAVE
    srmclean
    UsrPrmpt
    jusched
    SAdBlock
    SNDMon
    SynTPEnh
    SynTPLpr
    pokapoka6s
    realsched
    ypwoa
    wintask
    pcfagg
    ybinstall_1
    Adobe Reader Speed Launch
    America Online 8.0 Tray Icon
    drnc
    poxq
    Data Keeper
    Lime Wire on Startup
    PowerRegScheduler
    can anyone tell me what this means? and if there is anything here that may be causing my problem? Thank you if so!
    Compaq Presario 2190US   Windows XP  

    jaimeleighann, that MSCONFIG screen is saying that you've got a Qoologic adware infection, just like i've been saying (in all your other threads where i've tried replying to you).
    try replying to answers to your previous posts rather than spraying new threads all over the show. your current posting technique is obviously not helping you resolve this.

  • SQL Performance - Looking for a hint or suggestion on how to improve performance.

    I've linked several tables for the Sales Order, Delivery, and Invoicing. In essence, a query to show shipments and invoicing to a sales order.
    Throughput is poor....60 + seconds, so I am looking for a solution...perhaps /* + hints*/ techinques to improve the performance of this code.
    Here is a functional version of the code....
    /* Functionally tested join between OM, WSH, AR Tables */
    Select oeh.order_number
         , trx_number as invc_no
         , rctl.line_number as invc_line_no
         , rctl.inventory_item_id rctl_inventory_item_id
         , rctl.sales_order_line as SO_Line_No
         , oel.line_id
         , rctl.line_type
         , oel.ship_from_org_id as oel_ship_from_org_id
         , rctl.warehouse_id
         , oel.ordered_quantity
         , oel.shipped_quantity
         , oel.invoiced_quantity
         , rctl.UNIT_SELLING_PRICE
         , rctl.extended_amount
         , rctl.revenue_amount
         , wdd.delivery_detail_id
         , wnd.delivery_id
         , rctl.interface_line_attribute1  -- Sales Order Number
         , rctl.interface_line_attribute3  -- delivery_id (wsh)
         , rctl.interface_line_attribute6  -- Sales Order Line Id
      From apps.oe_order_headers_all oeh
         , apps.oe_order_lines_all oel
         , apps.wsh_delivery_details wdd
         , apps.wsh_new_deliveries wnd
         , apps.wsh_delivery_assignments wda
         , apps.ra_customer_trx_all rct
         , apps.ra_customer_trx_lines_all rctl
    Where oeh.header_id = oel.header_id                           
       and wdd.source_header_id = oeh.header_id
       and wdd.source_header_id = oel.header_id 
           and wdd.source_line_id = oel.line_id
           and wdd.SOURCE_CODE = 'OE'
       and wdd.delivery_detail_id = wda.delivery_detail_id
       and wda.delivery_id = wnd.delivery_id
       and rctl.interface_line_attribute1 = to_char(oeh.order_number)
          and rctl.interface_line_attribute6 = to_char(oel.line_id) --this is where explain plan cost is high!
           and rctl.org_id = oel.org_id
       and rctl.interface_line_attribute3 = to_char(wnd.delivery_id)
       and rctl.customer_trx_id = rct.customer_trx_id
       and rct.interface_header_context = 'ORDER ENTRY'
       and oeh.order_number = '99999' --enter desired sales order here....
    Order by 1,2,3,4;

    Can you provide your explain?
    Also, can you do an "set autotrace traceonly" and run it again and post results?  The results of that would help people here provide more reasonable suggestions.
    (Mine so far is only: avoid hints - that's a crutch and not solving the real problem).
    Are your statistics up to date?
    select table_name, last_analyzed from dba_tables
    where table_name in (
           'OE_ORDER_HEADERS_ALL OEH','OE_ORDER_LINES_ALL OEL','WSH_DELIVERY_DETAILS WDD',
           'WSH_NEW_DELIVERIES WND','WSH_DELIVERY_ASSIGNMENTS WDA','RA_CUSTOMER_TRX_ALL RCT',
            'RA_CUSTOMER_TRX_LINES_ALL RCTL' );

  • Desperate for a little help with VMware Fusion tools

    I tried the Fusion discussions group on this question but got nothing, so please don't tell me to try there; I already have.
    I am using VMare Fusion 2.0.6 on my MacBook running 10.6.4; Windows OS is XP Home edition, SP3
    I find more and more applications that previously did not work well in OSX are now running nicely on my MacBook (i.e., various applications from Garmin) and that I rarely boot up in Windows.
    However, not long ago I did boot up in Windows and saw the alert, “VMware tools is out of date. Choose the virtual Machine > Install VMwre Toold Menu.” I did so and it failed, miserably. I lost tools completely, everything was a bloody mess.
    I looked for help/a solution on the VMware site, found it, but it was beyond my capability. I simply could not figure out how to do what it was directing me to do.
    I moved my Virtual Machine folder from a backup of my MacBook back to the MacBook; I am back to a point where all is well but I am also, naturally, getting the “VMware tools is out of date. Choose the virtual Machine . Install VMwre Toold Menu.”
    When I choose "Virtual Machine . Install VMwre Toold Menu", I get this alert: You cannot install the VMware Tools package until the guest operating system is running. If your guest operating system is not running, choose cancel and install the VMware Tools Package later.
    Isn't the "guest operating system" OSX on my MacBook? Well of course it's running; how the heck could you be running Fusion if OSX isn't running? There must be something here I just don't understand.
    Does some kind soul have the time and patience to explain to me what I am obviously missing here so I can get on with it and update VMware Tools?
    Many, many thanks if someone can

    OK, here's the rest of the story.
    I followed the above instructions, sort of...
    Removed Tools as directed.
    A restart was required to finish the removal.
    Restarted, went to Virtual Machine > Install VMware Tools package and got the, for me, dreaded - Warning, you cannot install the VMware Tools package unless the guest operating system is running, etc., so I clicked on Cancel.
    I also got the Found New Hardware Wizard, which I cancelled out of.
    I went to Virtual Machine > CD/DVD > Choose a disk image and navigated to "/Library/Application Support/VMware Fusion/isoimages/windows.iso" as I was directed, clicked on Open, and nothing happened.
    In Windows, I then went to the CD/DVD drive, to run the setup.exe manually.
    Among the choices there I found both VMware Tools and VMware Tools 64 and forgot I was told to run setup.exe. I asked again and was told to run VMware Tools. I did so and that fixed it.
    Later, I was told that I should have chosen setup.exe NOT the VMware Tools.msi, but that since setup.exe calls the VMware Tools.msi it's probably a moot issue as long as I received a message that VMware Tools were successfully installed.
    So, I guess the correct thing would have been to run setup.exe, but running VMware Tools also did the trick.
    Hope this helps someone else out if they stumble across it.

  • Houston based Oilfield company looking for part time help

    i-Tec Well Solutions, a Houston Texas based company, is looking for someone to set up existing pressure transducers and load cells to work with existing Labview Signal Express software.  This should be a short term contract job, which would include:
    Wiring up all equipment for easy and frequent use.
    Installing software  on a dedicated shop computer.
    Programing the software for collecting pressure data and force data.
    Recommendations for purchasing additional equipment.
    Recommendations for purchasing additional equipment to equip existing analog pressure pumps.
    Design and build a stand-a-lone shop test cart for mounting/storing all essential equipment.
    If interested, please contact Dennis @ [email protected]
    i-TEC Well Solutions
    5535 Brystone Drive
    Houston, TX 77041
    web: www.i-tec.no
    email: [email protected]

    Hello Joe:
    Do you need someone on-site? I could offer you remote work with the best pool of designers and DPS experts? We have been using it since the initial publi release in 2011
    Email me if you are interested => [email protected]

  • Lab Manager 3 reports - SQL Queries - looking for some help

    Hi Everyone
    Our management has asked for metrics on the use of Lab Manager so I started looking around and noticed that none of the 3rd party tools support Lab Manager. I started to poke around the SQL database and managed to extract some info however my SQL knowledge is very limited. I am wondering if anyone out there has written their own queries or can help me sort some things out.
    I thought I would start a community thread as i'm sure I am not the only one out there looking to do this.
    This first query gives you the usernames and deploys in order
    SELECT *
    FROM Jobs
    WHERE (starttime > '02/01/2007') AND (object NOT LIKE 'VirtualRouter%') AND (operation LIKE 'JOB_Deploy') AND (object_type_full = 'Virtual Machine') and (status <> 3)
    This query gives you the daily deployments per organization
    SELECT convert(char(10), starttime, 101) as MonthYear, count(operation) as Deployments, bucket_name AS Organization
    FROM Jobs
    WHERE (operation LIKE 'JOB_Deploy')AND starttime BETWEEN '12/01/2006' AND '12/01/2009' AND (status <>3)
    GROUP BY convert(char(10), starttime, 101),bucket_name
    ORDER BY MonthYear
    This last query shows total deployments listed by username (someone helped me with this)
    SELECT U.username, COUNT(J.job_id) AS Deploys
    FROM  Jobs J INNER JOIN
                         Usr U ON J.user_id = U.user_id
    WHERE (J.object_type_full = 'Virtual Machine') AND (J.operation = 'JOB_Deploy') AND (starttime BETWEEN '12/01/2006' AND '12/01/2009')
    GROUP BY U.username
    I would like to know how to get some of the following:
    Top 10 Users (Query 3 lists the total deployments per user but i don't know how to have it display this)
    number of images created monthly (VM Templates / Workspace Configurations)
    number of images captured to the library monthly
    Biggest VMs
    Number of logins daily (to Lab Manager)
    Top 10 images checked out
    Images not used in x days
    Any help would be greatly appreciated

    Troubleshooting Queries for Lab Manager 4
    I always had the need to map the VM IDs in vSphere Client and public IPs to the actual user and organisation. Also, LUN and ESX relations I need from time to time.
    SQL file to show all deployed VMs in all configurations
    use LabManager
    go
    select
      right('000000' + convert(varchar,bvs.dir_id),6) + '-' + left(bvs.name,15) as "Name in VCeneter",
      left(bko.name,12) as "Organization",
      left(bkw.name,8) as "Workspace",
      left(us.fullname,20) as "User",
      left(cfg.name,25) as "Configuration",
      dir.chain_length as "Chain Length",
      left(ds.display_name,15) as "LUN",
      left(ms.display_name,26) as "ESX Server",
      rii.ip_addr as "Internal IP",
      rie.ip_addr as "External IP",
      left(bvs.vm_tools_version,7) as "VM Tools",
      bvs.vcpu_count "CPU Count",
      left(bvs.mem,5) as "Memeory",
      convert(varchar(19), bvs.date_created, 120) as "Created",
      convert(varchar(19), dvs.date_deployed, 120) as "Deloyed"
    from BucketVirtualServer bvs
      inner join Bucket bko on bko.bucket_id=bvs.OrganizationBucketId
      inner join Bucket bkw on bkw.bucket_id=bvs.bucket_id
      inner join ConfigurationView cfg on bvs.sg_id=cfg.sg_id
      inner join Usr us on us.user_id=bvs.user_id
      inner join FsDir dir on dir.dir_id=bvs.dir_id
      inner join Datastore ds on ds.datastore_id=dir.datastore_id
      inner join NetworkInterface ni on bvs.vs_id=ni.vs_id
      inner join ReservedIPAddress rii on rii.address_id=ni.ip_address_id
      left join ReservedIPAddress rie on rie.address_id=ni.ext_address_id
      inner join DeployedVirtualServer dvs on dvs.vs_id=bvs.vs_id
      inner join ManagedServer ms on ms.ms_id=dvs.ms_id
    where bvs.is_vrouter=0
    order by bvs.dir_id
    go
    Batch file
    osql -S localhost\LABMANAGER -E -i vmlist.sql -o vmlist.txt -w 1024 -n
    start notepad vmlist.txt
    SQL file to show all VMs in all configurations
    use LabManager
    go
    select
    right('000000' + convert(varchar,bvs.dir_id),6) + '-' + left(bvs.name,15) as "Name in VCeneter",
    left(bko.name,12) as "Organization",
    left(bkw.name,8) as "Workspace",
    left(us.fullname,20) as "User",
    left(cfg.name,25) as "Configuration",
    dir.chain_length as "Chain Length",
    left(ds.display_name,15) as "LUN",
    left(ms.display_name,26) as "ESX Server",
    rii.ip_addr as "Internal IP",
    rie.ip_addr as "External IP",
    left(bvs.vm_tools_version,7) as "VM Tools",
    bvs.vcpu_count "CPU Count",
    left(bvs.mem,5) as "Memeory",
    convert(varchar(19), bvs.date_created, 120) as "Created",
    convert(varchar(19), dvs.date_deployed, 120) as "Deloyed"
    from BucketVirtualServer bvs
      inner join Bucket bko on bko.bucket_id=bvs.OrganizationBucketId
      inner join Bucket bkw on bkw.bucket_id=bvs.bucket_id
      inner join ConfigurationView cfg on bvs.sg_id=cfg.sg_id
      inner join Usr us on us.user_id=bvs.user_id
      inner join FsDir dir on dir.dir_id=bvs.dir_id
      inner join Datastore ds on ds.datastore_id=dir.datastore_id
      inner join NetworkInterface ni on bvs.vs_id=ni.vs_id
      inner join ReservedIPAddress rii on rii.address_id=ni.ip_address_id
      left  join ReservedIPAddress rie on rie.address_id=ni.ext_address_id
      left  join DeployedVirtualServer dvs on dvs.vs_id=bvs.vs_id
      left  join ManagedServer ms on ms.ms_id=dvs.ms_id
    /* where bvs.is_vrouter=0 */
    order by bvs.dir_id
    go
    Batch file
    osql -S localhost\LABMANAGER -E -i vmlist_all.sql -o vmlist_all.txt -w 1024 -n
    start notepad vmlist_all.txt

  • SQL syntax for expert little help Access 2013

    Hi
    working example SQL local machine
    strData= "SELECT DISTINCT Detail, FamCode as Fam FROM Mat_Family ORDER BY FamCode" 
    cmbMatFam.RowSource=strData                                                                                                                                                                             
    working example SQL server machine (other computer)           
    Public Const ServerConnectionWith_RawMaterial_LV
    As  String=  
     "[ODBC;Description=Live;DRIVER=SQLServer;SERVER=SERVER;UID=Name;PWD=Password;DATABASE=RawMaterial_LV]." 
    strData= "SELECT DISTINCT Detail, FamCode as Fam FROM " &
    ServerConnectionWith_RawMaterial_LV & "Mat_Family ORDER BY FamCode"
    cmbMatFam.RowSource = strData
    working example SQL local machine
     strData = "SELECT Material_M.M_Code, Material_M.Family_Code, ISNULL(z_TotalBars.Bars, 0) AS tBars, ISNULL(z_TotalRes.rBars, 0) AS rBars, "
          strData = strData & "ISNULL(z_TotalBars.Bars, 0) - ISNULL(z_TotalRes.rBars, 0) AS Bal, Material_M.Material_Fam, Material_M.Type, Material_M.Series, "
          strData = strData & "Material_M.Specific, Material_M.Hardness, Material_M.BarLength, Material_M.Density, Material_M.cPound_Ft, Material_M.cPrice_Pound,"
          strData = strData & "Material_M.cPound_Bar, Material_M.cPrice_Bar, Material_M.cPrice_Date , Material_M.Description "
          strData = strData & "FROM Material_M LEFT OUTER JOIN z_TotalRes ON Material_M.M_Code = z_TotalRes.M_Code LEFT OUTER JOIN "
          strData = strData & "z_TotalBars ON Material_M.M_Code = z_TotalBars.M_Code "
          strData = strData & "WHERE (Material_M.Family_Code = '" & cmbMatFam.Column(1) & "') AND (ISNULL(z_TotalBars.Bars, 0) > 0)"
      Form_frmMaterialLookup.RecordSource = strData
    NOT working example SQL server machine (other computer)  ??????
     strData = "SELECT Material_M.M_Code, Material_M.Family_Code, ISNULL(z_TotalBars.Bars, 0) AS tBars, ISNULL(z_TotalRes.rBars, 0) AS rBars, "
          strData = strData & "ISNULL(z_TotalBars.Bars, 0) - ISNULL(z_TotalRes.rBars, 0) AS Bal, Material_M.Material_Fam, Material_M.Type, Material_M.Series, "
          strData = strData & "Material_M.Specific, Material_M.Hardness, Material_M.BarLength, Material_M.Density, Material_M.cPound_Ft, Material_M.cPrice_Pound, "
          strData = strData & "Material_M.cPound_Bar, Material_M.cPrice_Bar, Material_M.cPrice_Date , Material_M.Description "
          strData = strData & "FROM  " &
    ServerConnectionWith_RawMaterial_LV
    & "Material_M LEFT OUTER JOIN z_TotalRes ON Material_M.M_Code = z_TotalRes.M_Code LEFT OUTER JOIN "
          strData = strData & "z_TotalBars ON Material_M.M_Code = z_TotalBars.M_Code "
          strData = strData & "WHERE (Material_M.Family_Code = '" & cmbMatFam.Column(1) & "') AND (ISNULL(z_TotalBars.Bars, 0) > 0)"
      Form_frmMaterialLookup.RecordSource = strData
    Error Message
      Syntax error (missing operator) in query expression 'Material_M.MCode= z_TotalRes.M_Code LEFT OUTHER JOIN z_TotalBars ON Material_M.M_Code = z_TotalBars.M_Cod
    Usually I just add                   "
    & ServerConnectionWith_RawMaterial_LV & "                                              
    to a SQL statement and it works,but not this time
    (Tables  Material_M,         z_TotalRes,             z_TotalBars             are in RawMaterial_LV
    Database)
    Appreciate any suggestion Thanks

    parenthesis did the job, now adding
    "WHERE (ISNULL(z_TotalBars.Bars, 0) > 0) AND (Material_M.Family_Code = 'BZ')"
    Tested working Query
    SELECT Material_M.M_Code, Material_M.Family_Code, Material_M.Material_Fam, Material_M.Type,
    Material_M.Series,
    Material_M.Specific, Material_M.Hardness, Material_M.BarLength, Material_M.Density,
    Material_M.cPound_Ft, Material_M.cPrice_Pound,
    Material_M.cPound_Bar, Material_M.cPrice_Bar, Material_M.cPrice_Date
    , Material_M.Description
    FROM
    ([ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Deco2014$;DATABASE=RawMaterial_LV].Material_M
    LEFT OUTER JOIN
    [ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Password;DATABASE=RawMaterial_LV].z_TotalRes
    ON Material_M.M_Code = z_TotalRes.M_Code)                                                                                            
    LEFT OUTER JOIN
    [ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Password;DATABASE=RawMaterial_LV].z_TotalBars
    ON Material_M.M_Code = z_TotalBars.M_Code
    Not working Query
    SELECT Material_M.M_Code, Material_M.Family_Code, Material_M.Material_Fam, Material_M.Type,
    Material_M.Series,
    Material_M.Specific, Material_M.Hardness, Material_M.BarLength, Material_M.Density,
    Material_M.cPound_Ft, Material_M.cPrice_Pound,
    Material_M.cPound_Bar, Material_M.cPrice_Bar, Material_M.cPrice_Date
    , Material_M.Description
    FROM
    ([ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Deco2014$;DATABASE=RawMaterial_LV].Material_M
    LEFT OUTER JOIN
    [ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Password;DATABASE=RawMaterial_LV].z_TotalRes
    ON Material_M.M_Code = z_TotalRes.M_Code)                                                                                            
    LEFT OUTER JOIN
    [ODBC;Description=Live;DRIVER=SQL Server;SERVER=DSERVER;UID=Super;PWD=Password;DATABASE=RawMaterial_LV].z_TotalBars
    ON Material_M.M_Code = z_TotalBars.M_CodeWHERE (ISNULL(z_TotalBars.Bars, 0) > 0) AND (Material_M.Family_Code = 'BZ')
    Message Error
    Wrong number of arguments used with function in query expression '(ISNULL(z_TotalBars.Bars, 0) > 0) AND (Material_M.Family_Code = 'BZ')
    Works this way
    WHERE (z_TotalBars.Bars > 0) AND (Material_M.Family_Code = 'BZ')

  • I have a mac laptop and when i plug my ipod touch (fourth generation), the computer does not even know its there. I look for the little box where the devices usually are and there is nothing showing up. I need help.

    Additional info.
    This computer is a computer handed out to us from school that we use throughout highschool. We are allowed to sync our itunes accounts so theres no problem there.

    See:
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive: Apple Support Communities

Maybe you are looking for

  • Itunes store wont load - no error message :-/

    Hi everyone, Recently, for some unknown reason, itunes store will not load on my laptop. Strangely no error message appears it just starts loading and then stops half way through. I have tried diagnosis, repair, re-installing it completely, checking

  • What is boot camp? can i install it on my pc?

    sorry for the noob question but, i get the impression boot camp allows you to run windows on your mac. can you get it for the pc? if so what does it do for the pc? thanks!

  • Error signature EventType : BEX

    Brand new install of XP Pro, SP 3 and Reader 9.3 (Tried 8.2 - same results). Only when printing .pdf docs to a Canon iC D780 via a USB or Parallel cable does the user get the annoying Windows DEP error. I've already tried changing the DEP settings to

  • Monitor Shopping Carts with approval overview

    Hi experts, Do you know of any report similar to BBP_MON_SC that shows also the approval overview, or at least who is the current approver that has to release the Shopping Cart? Many thanks, Ezequiel

  • Non documented display indicator on E51

    Hello. I noticed there is a display indicator on my E51 that doesn't appear on the user guide (Issue 2). It's similar to an two X on crossover. You can see it here: Any idea what is this display indicator means? It's always there. Greetings.