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 9001041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:23:05+00:00 2026-06-16T00:23:05+00:00

The full error I get is: Msg 512, Level 16, State 1, Line 1

  • 0

The full error I get is:

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.

I was passed by this SQL code that used to work in the past and I need to fix it, but I get the error above, but even if I comment out some parts the error stays the same

Here is the sql code:

SELECT  
    OrderId = OrdNameAdd.ORDERS_ID,
    LTRIM(ISNULL(OrdNameAdd.OBY_FirstName, '') + ' ' + ISNULL(OrdNameAdd.OBY_LASTNAME, '')) AS OrderedByName,
    ObyVar1 = (SELECT varfld_value FROM MAILERVBL WHERE OBYMAILER = MAILERVBL.MAILER_SEQID AND VARDEF_SEQUENCE = 1),
    ObyVar2 = (SELECT varfld_value FROM MAILERVBL WHERE OBYMAILER = MAILERVBL.MAILER_SEQID AND VARDEF_SEQUENCE = 2),
    ObyVar3 = (SELECT varfld_value FROM MAILERVBL WHERE OBYMAILER = MAILERVBL.MAILER_SEQID AND VARDEF_SEQUENCE = 3),
    ExtendedDefaultValue = (SELECT sum(isnull(p.prduct_value,0) *  (isnull(pickdt.prdord_toshipqty,1))) 
                            FROM PICKDT 
                            LEFT OUTER JOIN 
                               locVerBals ON PICKDT.PRVERS_SEQID = locVerBals.PRVERS_Seqid 
                            LEFT OUTER JOIN 
                               LOCPRDSUM p ON locVerBals.PRDUCT_Seqid = p.PRDUCT_SEQID 
                                           AND p.system_id = PICPAK.SYSTEM_ID 
                            WHERE
                               PICKDT.PICPAK_Seqid = PICPAK.PICPAK_Seqid 
                               AND p.PRDUCT_INACTIVEDATE IS NULL), 
    FulfCharges = (rpt_BD.Linesshipped * ACCDEF_ChargePerLine) + ACCDEF_ChargePerShipment, 
    PubFreight = (rpt_BD.PubFreight), 
    TotalValue = 
        (SELECT 
            sum(isnull(p.prduct_value, 0) * (isnull(pickdt.prdord_toshipqty, 1))) 
         from PICKDT 
         LEFT OUTER JOIN locVerBals ON PICKDT.PRVERS_SEQID = locVerBals.PRVERS_Seqid 
         LEFT OUTER JOIN LOCPRDSUM p ON locVerBals.PRDUCT_Seqid = p.PRDUCT_SEQID 
                                     AND p.system_id = PICPAK.SYSTEM_ID 
         WHERE 
             PICKDT.PICPAK_Seqid = PICPAK.PICPAK_Seqid AND p.PRDUCT_INACTIVEDATE IS NULL) 
         + isnull((rpt_BD.Linesshipped * ACCDEF_ChargePerLine), 0) 
         + isnull(ACCDEF_ChargePerShipment,0) + isnull((rpt_BD.PubFreight), 0)
FROM 
    PICPAK 
LEFT OUTER JOIN 
    ORDSTO ON PICPAK.ORDSTO_Seqid = ORDSTO.ORDSTO_Seqid 
LEFT OUTER JOIN 
    OrdNameAdd ON ORDSTO.ORDERS_Seqid = OrdNameAdd.ORDERS_SEQID 
LEFT OUTER JOIN 
    Rpt_BillingDetail rpt_BD ON PICPAK.PICPAK_Seqid = rpt_BD.PICPAK_Seqid 

---------------hERE
WHERE 
    (convert(datetime, DateShipped, 1) >= '4/17/2012' 
     AND convert(datetime, DateShipped, 1) <= '12/17/2012')
---------------HERE

    AND (PICPAK.PICPAK_Status = 'Complete' OR PICPAK.PICPAK_Status = 'Shipped' 
         OR picpak_Status = 'Voided') 
    /*AND (p.PRDUCT_INACTIVEDATE IS NULL)*/
    AND ISNULL(PICPAK.SUPPLR_SEQID,0) = 0
GROUP BY
    OrdNameAdd.ORDERS_ID,
    OrdNameAdd.OBY_FirstName,
    OrdNameAdd.OBY_LASTNAME,
    OrdNameAdd.obymailer,
    PICPAK.PICPAK_Seqid,
    PICPAK.System_Id,
    rpt_BD.PubFreight,
    ACCDEF_ChargePerLine,
    ACCDEF_ChargePerShipment,
    rpt_BD.Linesshipped,
    rpt_BD.Numpackages,
    ordsto.orders_seqid
ORDER BY
    ordsto.orders_seqid ASC
  • 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-16T00:23:05+00:00Added an answer on June 16, 2026 at 12:23 am

    In your query, you have five subqueries for ObyVar1, ObyVar2, ObyVar3, ExtendedDefaultValue, and TotalValue.

    The two value subqueries are using aggregations with no group by, so they should be returning one value.

    Your problemis in the three ObyVars.

    There are simple two ways to get rid of this:

    1. Aggregate the values. So do max(varfld_value).
    2. Choose one value. In SQL Server, this would be a top 1 (in other databases, it might be rownum = 1 or limit 1).

    However, overall, I find select statements within select statements to be undesirable. I would replace those three variables with a subquery in the from clause:

    (select mailer_seqid,
            max(case when vardef_sequence = 1 then varfld_value end) as vv_1, 
            max(case when vardef_sequence = 2 then varfld_value end) as vv_2,
            max(case when vardef_sequence = 3 then varfld_value end) as vv_3
     from mailervbl
     group by mailer_seqid
    )
    

    In most cases, this should be as or more efficient than the three subqueries.

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

Sidebar

Related Questions

Full error below: Error 1 SQL01268: .Net SqlClient Data Provider: Msg 1834, Level 16,
I get this error: NoMethodError in Videos#new Showing /rubyprograms/dreamstill/app/views/videos/new.html.erb where line #1 raised: undefined
The full error I'm getting is this: error: ambiguous overload for ‘operator[]’ in ‘a[boost::_bi::storage4<A1,
This is the full error report that is generated when tried to compile my
How would I get my error message to be conditional like this: <% if
I got this error referring to line 3 in the view when I used
See the full error here: http://notesapp.heroku.com/ I'm using DataMapper and dm-validations 0.10.2. No matter
Seems like cuke doesn't show the full error message (at least when problem occurs
okay, the full error is 06-19 01:07:57.421: E/AndroidRuntime(4478): java.lang.RuntimeException: Error receiving broadcast Intent {
I am getting the common ASP.NET YSOD error. Here is the full error page

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.