Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:43:42+00:00 2026-06-09T11:43:42+00:00

I want to update with the value in this query, but it’s saying it

  • 0

I want to update with the value in this query, but it’s saying it returns more than one value.

UPDATE PO_HEADER
  SET TOTAL = (SELECT SUM(LINE_TOTAL) AS "NEW_LINE_TOTAL" 
  FROM PO_LINE pl, PO_HEADER ph 
  where ph.IC_PO_HEADER = pl.IC_PO_HEADER 
  and ph.RELEASE_NUMBER = pl.RELEASE_NUMBER 
  group by pl.IC_PO_HEADER,pl.FOREIGN_KEY,ph.RELEASE_NUMBER,
  ph.REVISION_NUMBER,ph.PO_NUMBER)
from PO_HEADER ph, PO_LINE pl
where ph.IC_PO_HEADER = pl.IC_PO_HEADER;

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.

How is it returning more than one column?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:43:43+00:00Added an answer on June 9, 2026 at 11:43 am

    If this query returns the information you want:

    SELECT *, LINE_TOTAL = SUM(l.LINE_TOTAL) OVER 
        (PARTITION BY l.IC_PO_HEADER, l.RELEASE_NUMBER)
      FROM dbo.PO_HEADER AS h
      INNER JOIN dbo.PO_LINE AS l
      ON h.IC_PO_HEADER = l.IC_PO_HEADER 
      AND h.RELEASE_NUMBER = l.RELEASE_NUMBER;
    

    Then this is probably the UPDATE query you want:

    ;WITH x AS
    (
      SELECT h.TOTAL, lt = SUM(l.LINE_TOTAL) OVER 
        (PARTITION BY l.IC_PO_HEADER, l.RELEASE_NUMBER)
      FROM dbo.PO_HEADER AS h
      INNER JOIN dbo.PO_LINE AS l
      ON h.IC_PO_HEADER = l.IC_PO_HEADER 
      AND h.RELEASE_NUMBER = l.RELEASE_NUMBER
    )
    UPDATE x SET TOTAL = lt;
    

    I have to agree with Gordon, your grouping seems very strange. I’m not sure if I got it right (which is why I strongly recommend you run the SELECT first).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to update the lastlogin column value .i wrote the code like this
I want to update and select one row within one query in SqLite. In
i want to update multiple value of my table ORDRE ? table ORDRE CP
I want to always update the value of an update row in the database.
I want to update a column by adding a new value alongside the old
I have two tables nol_art and #tmpIzm I want to update nol_art with value
I want to check a Column value when update.If its match insert into another
I would like to use jquery to update my attribute value, because I want
I want to update rows of a table in a specific order, like one
I query-ing this from entity framework using WCF, and i want to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.