SubQuery Issue

  • HI FOlks,

    I have problem with the below subquery and throwing this issue

    (Select (BudgetHigh+BudgetLow) as Budget

    from BDF_Form_Budget as fb

    LEFT OUTER JOIN BDF_tlkp_BudgetType AS bt ON fb.BudgetTypeId=bt.BudgetTypeID

    left outer join BDF_tlkpBudgetPlatform as pt on fb.PlatformId=pt.PlatformID

    where FormId=b.FormID )as TotalBudget

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

    please help me out to solve this.

    Thanks,

    Frank

  • As the error says, the subquery returns more than one row, which is not permitted in that context. You'll need to change the subquery to ensure that it only ever returns a single row. Are you missing a SUM/GROUP BY perhaps?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Based on what you posted, I suppose that you're not showing us all the code, but just a small portion of it.

    Can you share the whole statement, please?

    -- Gianluca Sartori

  • As GilaMonster states, in this subsquery it is returning more than one row which cannot happen, please show us the whole query or find a way through correlated subqueries or something to limit your query to one row only.

Viewing 4 posts - 1 through 3 (of 3 total)

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