Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, = or when the subquery is used as an expression.

  • Hello Everyone,

    My code is below. Can anyone tell me why I get this message:

    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

    Can someone please tell me how to fix it? Thanks in advance.

    SELECT d.ITEMNMBR, d.ITEMDESC, d.ABCCODE, d.UOMSCHDL, ISNULL

    ((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 6) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month6, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 5) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month5, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 4) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month4, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 3) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month3, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 2) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month2, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) - 1) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month1, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE())) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS CurrentMonth, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 6) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth6, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 7) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth5, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 8) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth4, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 9) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth3, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 10) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth2, ISNULL
    ((SELECT SUM(TRXQTY) * - 1 AS Expr1
    FROM IV30300 AS a
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (DOCTYPE IN (1, 6)) AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJRTS') AND

    (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) <> 'IVADJADJ') AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm,
    GETDATE()) + 11) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth1, e.VENDORID, ISNULL
    ((SELECT QTYONORD AS Expr1
    FROM IV00102 AS f
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (LOCNCODE = '')), 0.0) AS QtyOnOrder, ISNULL
    ((SELECT SFTYSTCKQTY AS Expr1
    FROM IV00102 AS f
    WHERE (ITEMNMBR = d.ITEMNMBR) AND (SFTYSTCKQTY > 0)), 0.0) AS SafetyStock, ISNULL

    ((SELECT QTYONHND AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR) AND (LOCNCODE = '')), 0.0) AS QtyOnHand, ISNULL

    ((SELECT PRCHSNGLDTM / 7 AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR) AND (LOCNCODE = '')), 0.0) AS Planning_Lead_Time, e.VENDORID AS Supplier, e.PLANNINGLEADTIME,

    g.CMPTITNM, DATEPART(MM, GETDATE()) AS This_Month

    FROM BOM50100 AS g LEFT OUTER JOIN

    IV00101 AS d ON g.CMPTITNM = d.ITEMNMBR LEFT OUTER JOIN

    IV00103 AS e ON d.ITEMNMBR = e.ITEMNMBR LEFT OUTER JOIN

    IV30300 AS b ON d.ITEMNMBR = b.ITEMNMBR

    WHERE (d.ITEMTYPE <> 2)

    GROUP BY g.CMPTITNM, d.ITEMNMBR, d.ITEMDESC, d.ABCCODE, d.UOMSCHDL, e.VENDORID, e.PLANNINGLEADTIME

  • Looks like line 66:

    GETDATE()) + 11) AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth1, e.VENDORID, ISNULL

    You are sending 2 values to the isnull statement here.

  • When using a subquery in the select statement the subquery can only return a single value. One (or more) of your subqueries is returning more than one value. You should execute each individually to determine which one is returning multiple rows.

    Gordon Pollokoff

    "Wile E. is my reality, Bugs Bunny is my goal" - Chuck Jones

  • Ok. Thanks to everyone for their help.

  • I'd just like to say that if you want help and quickly then in future you should post your code like I've done at the end of this post. I find it much easier to read code that is posted in this way. The code directly below is where you should look, it's highly probable that these 3 in line select queries are returning more than one value. 🙂

    SELECT QTYONORD AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (LOCNCODE = '')

    SELECT SFTYSTCKQTY AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (SFTYSTCKQTY > 0)

    SELECT QTYONHND AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (LOCNCODE = '')

    ... (in future format your code as below)...

    SELECT

    d.ITEMNMBR,

    d.ITEMDESC,

    d.ABCCODE,

    d.UOMSCHDL,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 6)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month6,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 5)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month5,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 4)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month4,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 3)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month3,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 2)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month2,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) - 1)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS Month1,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()))

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()))), 0.0) AS CurrentMonth,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) + 6)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth6,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) + 7)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth5,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) + 8)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth4,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0)

    AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) + 9)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth3,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY < 0) AND (DATEPART(MM, DOCDATE) = DATEPART(mm, GETDATE()) + 10)

    AND (DATEPART(year, DOCDATE) = DATEPART(year, GETDATE()) - 1)), 0.0) AS PyrMonth2,

    ISNULL((SELECT SUM(TRXQTY) * - 1 AS Expr1

    FROM IV30300 AS a

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (DOCTYPE IN (1, 6))

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJRTS')

    AND (LEFT(TRXSORCE, 5) + LEFT(DOCNUMBR, 3) 'IVADJADJ')

    AND (TRXQTY 0)), 0.0) AS SafetyStock,

    ISNULL((SELECT QTYONHND AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (LOCNCODE = '')), 0.0) AS QtyOnHand,

    ISNULL((SELECT PRCHSNGLDTM / 7 AS Expr1

    FROM IV00102 AS f

    WHERE (ITEMNMBR = d.ITEMNMBR)

    AND (LOCNCODE = '')), 0.0) AS Planning_Lead_Time,

    e.VENDORID AS Supplier,

    e.PLANNINGLEADTIME,

    g.CMPTITNM,

    DATEPART(MM, GETDATE()) AS This_Month

    FROM BOM50100 AS g

    LEFT OUTER JOIN IV00101 AS d ON g.CMPTITNM = d.ITEMNMBR

    LEFT OUTER JOIN IV00103 AS e ON d.ITEMNMBR = e.ITEMNMBR

    LEFT OUTER JOIN IV30300 AS b ON d.ITEMNMBR = b.ITEMNMBR

    WHERE (d.ITEMTYPE 2)

    GROUP BY g.CMPTITNM, d.ITEMNMBR, d.ITEMDESC, d.ABCCODE, d.UOMSCHDL, e.VENDORID, e.PLANNINGLEADTIME

    ----------------------------------------------------------------------------------------------
    Struggling to find the question?
    http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx

  • I don't think anyone has mentioned it, but man, is that query going to run slowly. All those correlated sub-queries are going to be painful. You might want to explore moving them out of the SELECT list and into the FROM list, still as sub-queries. SQL Server will do some of that on it's own, but when the query is this complicated, it's unlikely to get a full optimization. If you look at the actual execution plan and the SELECT operation, I'll bet it says Time Out in the reason for aborting the optimization.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you for all the feedback so far.

    I am a bit surprised the SQL Management Studio is interpreting my code as sub-queries. Can someone please explain why? I don't think they are subqueries. My understanding of subqueries is as follows in this example:

    Use example

    select fname, lastname

    from table

    where location_no = (select location_no

    from location

    where location_no = 'Dallas')

    The above could be considered a sub-query. Do you all agree or am I off the track?

  • What you have are what are referred to as correlated sub-queries. As a general concept, they're not bad or dangerous, but when over-applied, and I think you're there, they become so.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • OK. Thanks for your help.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply