Finding this error when running the below query - Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

select 
min(h.[Spcl Order]),
(select (case when sum(pro.[Quantity]) is null then 0 else sum(pro.[Quantity]) END))
+
(select (case when sum(A.[Quantity]) is null then 0 else sum(A.[Quantity]) END),
min(b.[Posting Date]),min(c.[Order No]),min(d.[Prod_Order No]),min(e.[No]),
min(f.[Item Category Code]),min(g.[Location Code]),min(i.[Spcl Order_Purch])
from [tablename2] A 
inner join [sample].[dbo].[Posting Date_PRL] as b on a.[Posting Date]=b.[Posting Date]
inner join [sample].[dbo].[Order No_PRL] as c on a.[Order No_]=c.[Order No]
inner join [sample].[dbo].[Prod_ OrderNo_PRL] as d on a.[Prod_ Order No_]=d.[Prod_OrderNo] 
inner join [sample].[dbo].[No_PRL] as e on a.[No_]=e.[No]
inner join [sample].[dbo].[Item Category Code_PRL] as f on a.[Item Category Code]=f.[Item Category Code]
inner join [sample].[dbo].[Location Code_PRL] as g on a.[Location Code]=g.[Location Code]
inner join [sample].[dbo].[Spcl Order_PRL] as i on a.[Spcl Order]=i.[Spcl Order_Purch]
where ((A.[Item Category Code] = 'STYLES') and (A.[Prod_ Order No_]='') and ( A.[Buy-from Vendor No_] in ('S02052')) AND (A.[Quantity]>0) 
AND ( A.[Posting Date] = pro.[Finished Date])))
from [tablename1] pro 
inner join [sample].[dbo].[Spcl Order_PO] as h on Pro.[Spcl Order]=h.[Spcl Order]
where ((pro.[Status]=4) and (pro.[Finished Date] ='2013-10-10' )) group by pro.[Finished Date]

As other suggested, please find the column list...there are many columns in your subquery...
eg:
Select *,(Select 1,2) From (Values(1),(2))A(MonthID) -- will not work
where as 
Select *,(Select 1) From (Values(1),(2))A(MonthID) --will work
Your case:
select 
min(h.[Spcl Order]),
(select
(case when sum(pro.[Quantity]) is null then 0 else sum(pro.[Quantity]) END))
+
(select (case when sum(A.[Quantity]) is null then 0 else sum(A.[Quantity]) END),
min(b.[Posting Date]),min(c.[Order No]),min(d.[Prod_Order No]),min(e.[No]),
min(f.[Item Category Code]),min(g.[Location Code]),min(i.[Spcl Order_Purch])
from [tablename2] A 
inner join [sample].[dbo].[Posting Date_PRL] as b on a.[Posting Date]=b.[Posting Date]
inner join [sample].[dbo].[Order No_PRL] as c on a.[Order No_]=c.[Order No]
inner join [sample].[dbo].[Prod_ OrderNo_PRL] as d on a.[Prod_ Order No_]=d.[Prod_OrderNo] 
inner join [sample].[dbo].[No_PRL] as e on a.[No_]=e.[No]
inner join [sample].[dbo].[Item Category Code_PRL] as f on a.[Item Category Code]=f.[Item Category Code]
inner join [sample].[dbo].[Location Code_PRL] as g on a.[Location Code]=g.[Location Code]
inner join [sample].[dbo].[Spcl Order_PRL] as i on a.[Spcl Order]=i.[Spcl Order_Purch]
where ((A.[Item Category Code] = 'STYLES') and (A.[Prod_ Order No_]='') and ( A.[Buy-from Vendor No_]
in ('S02052')) AND (A.[Quantity]>0) 
AND ( A.[Posting Date] = pro.[Finished Date])))
from [tablename1] pro 
inner join [sample].[dbo].[Spcl Order_PO] as h on Pro.[Spcl Order]=h.[Spcl Order]
where ((pro.[Status]=4) and (pro.[Finished Date] ='2013-10-10' )) group by pro.[Finished Date]

Similar Messages

  • Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    hi all
    i have a table that name is:
    TiketsHeader 
    but i used this code
    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    i see this error:
    Msg 116, Level 16, State 1, Line 2
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    how to solve it
    please help me
    Name of Allah, Most Gracious, Most Merciful and He created the human

    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    A Sub query like this can only return one column, not serveral like here with the star *. Replace the star by one column Name that you want to query.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Msg 116, Level 16, State 1, Line 6 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    Hello,
    Can anyone help me?
    select year(po.rdata) as 'Ano', 
    sum(etotal) as 'Valorp' ,
    (select year(fo.data),Sum(etotal) 
    FROM fo (nolock) 
    where  not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode ) 
    group by year(fo.data))as 'Valorap'   
    from po 
    group by year(po.rdata)
    order by year(po.rdata)
    Error 
    Msg 116, Level 16, State 1, Line 6
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    Consultora

    Hi Prashanth,
    select year(po.rdata) as 'Ano',
    sum(etotal) as 'Valorp' ,
    (select Sum(etotal)
    FROM fo (nolock)
    where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
    group by year(fo.data))as 'Valorap'
    from po(nolock)
    group by year(po.rdata)
    order by year(po.rdata)
    Gives me the error: 
    Msg 512, Level 16, State 1, Line 1
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    Thanks
    Consultora

  • Error Only one expression can be specified in the expression list when the subquery is not intriduced. Please help

    Please help to fix this error
    SELECT    A.FLEETID,
    (SELECT   b.fleetid,SIZE,MAKE,PATTERN FROM ROQFLEETCHECK B
             WHERE  B.AxleNo=1  and B.AxleType = 'OFFSIDE OUTER' AND B.FLEETID = 1819 and B.fleetid =  A.fleetid) AS fleetList
    FROM ROQFLEETCHECK    AS A WHERE  a.FLEETID = 1819;
    Regards
    Pol
    polachan

    Hi,
    In addition to
    Naarasimha's answer. a small clarification: As much as the query optimizer the sub query "SELECT...
    FROM ROQFLEETCHECK B WHERE  ..."  might return more then one value and therefore it raise this error. What you can do, is limit
    the returned value to one, using "top 1" or aggregate function (as
    Naarasimha suggested).
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?

    I want to be the only one who can access my profile, so how to create passwords for profiles (NOT for websites) ?
    thanks

    Maybe use the portable Firefox version on a USB stick if you want to prevent access to your profile.<br />
    Solutions that use an extension can easily be bypassed by starting in [[Safe mode]].<br />
    Otherwise you need to locate the Firefox profile folder on an encrypted drive.
    See http://portableapps.com/apps/internet/browsers/portable_firefox

  • How do you lock the ipad so only one app can be used

    I want to force a student to communicate using an ipad communication app.  I want the only thing on the screen to be that one app.  How do I lock the app so it is the only one that can be used on the ipad?   Is there a way to lock a page?  ie when he has navigated to the correct page to prevent the child from exiting and make him make a choice from that page?
    Thanks!

    You can lock an iPad to a given app via Guided Access:
    http://support.apple.com/kb/HT5509
    To try and lock a web browser to a single page you'll need to investigate third-party browsers such as MobiCIP or the McGruff browser and see if they allow you to lock to a single page. Safari in iOS 6 or earlier has no controls and in iOS 7 allows you to restrict to a given site or set of sites but not to a single web page.
    Regards.

  • HT202157 Am I the only one who can't get their Apple TV to update the software?

    I was wondering why I cant update my Apple TV to the new software. Im thinking that it cant be updated until March 16th but im not sure.

    i updated mine just fine this morning.  what happens when you try to update?  are you getting an error, is it not finding an update, it is emitting a mild nuerotoxin that causes you to passout while gnomes steal your socks?  without more detail im not really sure how to help
    -mvimp

  • Is there a way to block one of the monitors, so only one app can use it?

    Ok, here is the story: Right now I'm using Logitech G15 keyboard. It's almost 10 years old, so it's time to buy something new. However, I'm quite used to having additional screen with computer info (date/time/CPU and RAM usage/temp/etc) without switching my
    Windows. However, Logitech G19s is the last keyboard with screen feature and it's still quite ridiculously expensive. So - my idea is to create my own "screen with PC info".
    There are some 5-10 inch screens that I could plug in and create a full screen app, that will show all the data I need. However, having a 5 inch screen connected could mess up my "workflow" on my full size monitors.
    So, my question is: Is there a way to create an app, that runs on system start, takes "ownership" of that small monitor, disabling it for Windows to (for example) extend desktop?

    Hello Quarien,
    >>Is there a way to create an app, that runs on system start, takes "ownership" of that small monitor, disabling it for Windows to (for example) extend desktop?
    If I understand correctly, you want your application to be displayed on the extended screen, if it is, you could have a try the
    SetWindowPlacement function and
    GetWindowPlacement function to determines the monitor the app runs on, for details, you could check this link:
    http://stackoverflow.com/questions/52755/what-determines-the-monitor-my-app-runs-on
    And if you are using C#, there is a demo example:
    public partial class Form1 : Form
    [DllImport("user32.dll")]
    static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);
    [StructLayout(LayoutKind.Sequential)]
    private struct WINDOWPLACEMENT
    public int length;
    public int flags;
    public int showCmd;
    public System.Drawing.Point ptMinPosition;
    public System.Drawing.Point ptMaxPosition;
    public System.Drawing.Rectangle rcNormalPosition;
    //Definitions For Different Window Placement Constants
    const UInt32 SW_HIDE = 0;
    const UInt32 SW_SHOWNORMAL = 1;
    const UInt32 SW_NORMAL = 1;
    const UInt32 SW_SHOWMINIMIZED = 2;
    const UInt32 SW_SHOWMAXIMIZED = 3;
    const UInt32 SW_MAXIMIZE = 3;
    const UInt32 SW_SHOWNOACTIVATE = 4;
    const UInt32 SW_SHOW = 5;
    const UInt32 SW_MINIMIZE = 6;
    const UInt32 SW_SHOWMINNOACTIVE = 7;
    const UInt32 SW_SHOWNA = 8;
    const UInt32 SW_RESTORE = 9;
    public Form1()
    InitializeComponent();
    private void Form1_Load(object sender, EventArgs e)
    WINDOWPLACEMENT param = new WINDOWPLACEMENT();
    param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
    param.showCmd = 5; //SW_SHOWNORMAL
    param.ptMaxPosition.X = 100;
    SetWindowPlacement(this.Handle, ref param);
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to execute the output of the below query automatically

    Hi All,
    I want to execute the output of the below query automatically, instead of manually copying it and execute.
    select 'alter database ['+name+'] set recovery simple' from master.sys.databases where database_id > 4 and state_desc = 'online'
    Please provide me a script to do this.
    ThanK
    Kate

    EXEC sp_MSforeachdb N'ALTER DATABASE [?] SET recovery simple';--- This will set the recovery model for all the system database.The query provided by Vikash16, meets my requirement. Thank you.

  • Sharing iTunes library/playlist, only one user can run iTunes

    Greetings everyone
    Just got a new aluminum iMac, setting it up for the wife and kids. From the descriptions here, I have set up several accounts to share a single iTunes library, by creating aliases in each user's iTunes folder that point to the shared library. It seems to work great: I only have to import music ONCE (instead of once for each user), and if one user creates or changes a new playlist, everyone sees it, which is exactly what I wanted.
    However, I have run into a small problem, and it is this. Under this setup, with everyone sharing the same library, *only one person can be running iTunes at a time.* If user A is running iTunes and doesn't quit the app when the computer is switched to User B or C, they get the message
    ----- +"The iTunes Library is locked, on a locked disk, or you do not have write permission for this file."+
    ----- Switch back to User A, quit iTunes, and then the others can launch iTunes fine (though again, just ONE of them). Same behavior regardless of whether the user is admin or not.
    So, is there any way to enable more than one user to run iTunes at once under this shared scenario? I'm thinking iTunes may not allow multiple users to access the library file at once, so it may be necessary to have users quit iTunes or log out before switching accounts. Let me know if there is a workaround or if anyone has gotten this to work....
    Thanks in advance!
    sno-man

    Hi, I just read your post here - I'd like to do exactly what you were able to do, that is, sharing one iTunes library with multiple user accounts on my iMac so that we can both use/add to the same library (I also want to do this with iPhoto, so I'm assuming it's the same process); would you mind quickly telling me how you were able to do this? I've been checking around and can't find a reliable answer. I'd appreciate it - thanks!

  • I am getting "Invalid Identifier" while running the below query

    Iam getting the error "Invalid Identifier, c_rank" while running the below query. Please help.
    select a.*, b.pog_description pog_description, b.start_date,
    row_number() over(partition by b.pog_description order by b.start_date) c_rank
    from temp_codi_dept_35 a, pog_master_msi b, pog_skus_msi c
    where a.sku = c.pog_sku
    and b.pog_id = c.pog_id
    and b.pog_dept = c.pog_dept
    and b.pog_number = c.pog_number
    and b.pog_level = c.pog_level
    and a.sku = 10263477
    and c_rank = 1;

    >
    Iam getting the error "Invalid Identifier, c_rank" while running the below query. Please help.
    select a.*, b.pog_description pog_description, b.start_date,
    row_number() over(partition by b.pog_description order by b.start_date) c_rank
    from temp_codi_dept_35 a, pog_master_msi b, pog_skus_msi c
    where a.sku = c.pog_sku
    and b.pog_id = c.pog_id
    and b.pog_dept = c.pog_dept
    and b.pog_number = c.pog_number
    and b.pog_level = c.pog_level
    and a.sku = 10263477
    and c_rank = 1;
    >
    You can't use 'c_rank' in the where clause because it doesn't exist; you are computing it in the SELECT clause.
    Remove the last condition and wrap your query in another one to select by 'c_rank'.

  • Inquiring minds may find this error code helpful: 0x207

    Hopefully I'm asking this in the right forum. I just downloaded the update for Microsoft Remote Desktop for Windows Phone 8.1 (I am actually running Denim on a 1520 but that may not matter). The version is 8.1.8.13 released 3/4/2015. I am trying to connect
    to a RemoteApp application but I am receiving the following error message shortly after it tries the redirection process (I think it fails at the securing remote connection part after it attemps the redirction to the RemoteApp application collection server):
    Connection error
    We couldn't connect to the remote PC. This might be due to an expired password. If this keeps happening, ask your admin or tech support for help.
    Inquiring minds may find this error code helpful: 0x207
    I am able to connect directly to both the broker server as well as the RemoteApp collection server with this application with the same credentials and am only experiencing this when trying to connect to a RemoteApp application.
    We are running Server 2012 R2 for both the broker/web and the collection servers. We are not using a gateway server as we use an SSL VPN concentrator instead for access outside of our network. We have server farms set up as well in the RemoteApp topology.
    Any info would help or let me know if I'm not posting in the right forum for this issue. I know this is a very recent release so I'm trying to figure out if I should wait for a bug fix or if there's something that I can do on my end.
    Thank you in advance for your time!

    Hi Scott,
    Please check your configuration once again and the certificate must be well configured. Also for accessing RemoteApp there might be the permission issue for your use, recheck once and verify. You can also got through
    this article for information.
    Hope it helps!
    Thanks.
    Dharmesh Solanki
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • When I publish my site on one specific page where i've added {tag_pagecontent} I get the error:Some files on the server may be missing or incorrect. Clear browser cache and try again. If the problem persists please contact website author.

    When I publish my site on one specific page where I've added {tag_pagecontent} I get the error:
    'Some files on the server may be missing or incorrect. Clear browser cache and try again. If the problem persists please contact website author.'
    I'm trying to get a blog module going, I've even deleted the html insert bog with the tag in and re-published which then I don't get the error but as a result no blog either. But then I add the tag in again and publish the error comes back. I've used the dev console and it says that my musicians sample.css is out of date but why is it only out of date when I add in html to my muse site?
    HELP!!!! I've searched other threads and to no avail I'm publishing so no direct ftp going on. the only thing I changed in business catalyst was the module stylesheet in order to style the blog. I've tried uploading and replacing all files nothing seems to work. the site is here:
    http://www.musicstudentsforhire.co.uk/musicians-samples.html
    It's only this page as it has the blog on. Also I've noticed when I've re-published occasionally it will show the mobile version on my desktop and not the desktop version??? no idea why that's happening so I've had to turn that off. any explanation on why that is happening would also be much appreciated.

    I haven't received an answer as of yet, I'll post t on here when I do. I de-activated the mobile site because it's my clients site so he needs it to be operational during the day. I hope someone gives me an answer soon.

  • How the below query is working

    Hi,
    I am newly joined in the group.
    the emp table has 5 rows as below
    100     ram     10000.00     10
    200     kumar     15000.00     10
    300     william     20000.00     10
    400     ravi     25000.00     10
    500     victor     30000.00     10
    i execute the below query
    select ename,sal from emp_test where case when sal < 10000 then sal + 1000
    when sal < 20000 then sal + 2000
    else sal
    end < 20000
    it gives the below output
    ram     10000.00
    kumar     15000.00
    How the above query is working?
    Please explain. thanks in advance

    If you want it to show the changed salary, it has to be in the select line not the where:
    select ename,
           (case when sal < 10000 then sal + 1000
               when sal < 20000 then sal + 2000
               else sal
            end) sal from emp_test
    where  case when sal < 10000 then sal + 1000
               when sal < 20000 then sal + 2000
               else sal
            end < 20000

  • Request for tunning the below query

    Hi,
    Can any one help me on the below query while improving the performance,
    SELECT accdet, acceprec, accinvalid, accnetanal, accphy, accvalid,
    actlabcost, actlabhrs, actualcontactdate, actualfinish, actualstart,
    affecteddate, affectedemail, affectedperson, affectedphone,
    alteration, aslaiddwg, assetnum, assetorgid, assetsiteid,
    assumptions, basedet, basereq, bicounty, bidplo, bieasting,
    bihousename, bihouseno, binorthing, bipobox, bipostcode, biposttown,
    bistreet, bisubb as bisupp, boostcomp, boostcompdet, ccemail, cchouseno, ccid,
    ccname, cctel1type, cctel2type, cctelephone1, cctelephone2, cdm,
    changeby, changedate, CLASS, classstructureid, cocontact, cocounty,
    codplo, coeasment, coeasting, cohousename, conorthing, copobox,
    commodity, commoditygroup, coneasereq, consent, consents,
    copostcode, coposttown, costcon, costreet, cosubb, cpi90,
    createworelasset, customerref, custtype, depot, description, durt,
    ecvpressuretier, ecvsize, enduserid, engdifficult, exaoq, existin,
    existsdq, expid, exshq, externalrecid, extralanddetail, failurecode,
    fr1code, fr2code, fuelpovscheme, g17, gbna, glaccount,
    globalticketclass, globalticketid, govconf, govener, govenerdet,
    govhouse, hasactivity, hasld, historyflag, impact, infill,
    infoprovide, inheritstatus, internalpriority, interquote, isglobal,
    isknownerror, isknownerrordate, kioskdet, kioskreq, langcode,
    latecertdate, leadt, lengthpri, lengthpub, loadtype, LOCATION, m25,
    maindesac, mainusage, meterboxty, metercon, meterloc, meterser,
    mininforec, mininforeq, mprnno, newaoq, newpid, newsdq, newshq,
    np14, nrswa, nsgno, oldquotever, oldticketid, orgid, originsgn,
    origrecordclass, origrecordid, origrecorgid, origrecsiteid, owner,
    ownergroup, packagesent, paymethod, payterms, permittowork, physub,
    pressuretier, privateexc, problemcode, propertiesno, propertytype,
    publicexc, purgerel, quotedate, quotetype, quotever, reinforcement,
    reinforcementa, reinforcementb, relatedtoglobal, reportdate,
    reportedby, reportedemail, reportedphone, reportedpriority,
    rowstamp, sc, scj, scoreq, servicerelay, sgnbillcontact,
    sgnblkbyfin, sgncusttobill, sgncusttosite, sgndisreasoth,
    sgneasment, sgnenhance, sgneow, sgneowreq, sgngqmvalid,
    sgninfillcost, sgninfillver, sgninfprojno, sgnisstdchrg,
    sgnloadnoenter, sgnmainsreq, sgnmaxaccdate, sgnnoncont, sgnpipesiz,
    sgnpurord, sgnqdaysremain, sgnqstd, sgnquotdate, sgnquotval,
    sgnreasdis, sgntotalaoq, sgntotalshq, sgnvarreq, sicontact,
    sicounty, sidplo, sieasting, sihousename, sihouseno, sinorthing,
    sipobox, sipostcode, siposttown, sistreet, sisubb, sitecond, sitegt,
    siteid, sitel1, sitel2, siteplpro, sitevisit, solution, sos,
    sosrecdate, SOURCE, status, statusdate, subfinal, supervisor,
    supplytype, surveycarr, surveydef, surveyreas, surveyreq, surveyret,
    surveysent, targetcontactdate, targetfinish, targetstart, TEMPLATE,
    templateid, termtype, thirdpartyeas, thirdpartypipe, ticketid,
    ticketuid, totalaoq, totalpid, totalsdq, totalshq, traffictime,
    typewo, urgency, variat, vendor, customer_enquiry_ref,
    quote_version, costs, mains_infill_charge, mtr_housing_kiosk_charge,
    mtr_housing_kiosk_base_charge, specialist_reinstatement,
    easement_charge, total_quote_ex_vat, vat, total_quote_incl_vat,
    design_charge, reinforcement_charge, reinforcement_cost,
    connection_allowance, workorder.pscdate, workorder.ascdate,
    workorder.fincode, workorder.istask, workorder.status,
    workorder.targstartdate, workorder.targcompdate,
    workorder.schedfinish, workorder.actfinish, workorder.estdur,
    workorder.wonum, workorder.mprn,
    workorder.sihousename AS wositehousename,
    workorder.sihouseno AS wositehouseno,
    workorder.sistreet AS wositestreet,
    workorder.sicounty AS wositecounty,
    workorder.siposttown AS wositeposttown,
    workorder.sipostcode AS wositepostcode, workorder.workorderid
    FROM (maximo.sr
    INNER JOIN
    (maximo.relatedrecord INNER JOIN maximo.workorder
    ON relatedrecord.relatedreckey =
    (CASE
    WHEN workorder.PARENT IS NOT NULL
    THEN workorder.PARENT
    ELSE workorder.wonum
    END
    AND relatedrecord.orgid = workorder.orgid
    AND relatedrecord.siteid = workorder.siteid
    AND relatedrecord.relatedrecclass = 'WORKORDER')
    ON sr.ticketid = relatedrecord.recordkey
    AND sr.orgid = relatedrecord.orgid
    AND sr.siteid = relatedrecord.siteid
    AND relatedrecord.CLASS = 'SR')
    LEFT JOIN
    frozen_quote@gqmfof
    ON sr.ticketid = customer_enquiry_ref
    AND sr.quotever = quote_version
    Regards,
    grace

    Could you please provide more info.
    Refer to the following link.
    When your query takes too long ...
    thanks

Maybe you are looking for