简体   繁体   中英

Subquery returned more than 1 value. This is not permitted when the subquery follows =,!=, <, <= , >, >= …?

Hi i wrote a following query but when i run,it is showing me following exception:

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



SELECT   ITEM_MODEL,
         ITEM_NAME,
         ITEM_DESCRIPTION,
         VENDOR_NAME,
         (Select QUANTITY from ITEMS_MASTER ),
         RATE=(CASE WHEN Discount IS NULL OR Discount=0 THEN RATE ELSE 
         RATE-(RATE*(Discount/100)) END),
         AMOUNT=(CASE WHEN Discount IS NULL OR Discount=0 THEN AMOUNT ELSE 
         AMOUNT-(AMOUNT*(Discount/100)) END) ,
         INVOICE_NUM, 
         DATE, 
         Discount 
         FROM ITEM_DETAILS ORDER BY ITEM_MODEL

This was working perfectly before but i dont know what happened with it suddenly i know it's unbelievable but unfortunately i'ts true ;) ..Any help would be highly appreciable.

There is surely an issue with the (Select QUANTITY from ITEMS_MASTER ), line. First of all the logic seems broken as there is no correlation between the two tables.

Maybe there should be a join with the ITEMS_MASTER table based on the item Id and then a simple select of the QUANTITY field without the use of a sub-query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM