Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Syntax help
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01416815
Message ID:
01416818
Vues:
33
Daniel,

The error message tells you exactly what the problem is. If you want just one value, add TOP 1 and ORDER BY to your subqueries.

It also would be much better to re-write this query to use derived tables instead.

>Brain freeze... I added two more columns to the below listed query and getting the following error:
>
>Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, or when the subquery is used as an expression.
>
>What am I missing?
>
>Thank you,
>DAniel
>
>
>select ....,
>DSPQOH = (select TOP1 (NJUseable + NVUseable) from ItemMst  
>             join PItems on ItemMst.DSP = PItems.ItemNo join History on PItems.EDPNo = History.EDPNo  
>             where itemmst.EDPNo = ItemMst.EDPNo order by SomeField),  
>NFSQOH = (select (NJUseable + NVUseable) from ItemMst  
>             join PItems on ItemMst.NFS = PItems.ItemNo join History on PItems.EDPNo = History.EDPNo  
>             where itm.EDPNo = ItemMst.EDPNo) 
>
>From itemmst itm 
>	left join DS1.dbo.WebCrawler wc on itm.ItemNo = wc.AMSSKU
>	join history on itm.EDPNo = History.EDPNo
>	join ProdType on itm.prodtype = prodtype.codno
>	join ProdFam on itm.prodfam = prodfam.codno
>	join PItems on itm.EDPNo = PItems.EDPNO
>	join poffers on PItems.edpno = poffers.edpno
>	join forecast on PItems.edpno = forecast.edpno
>	join VendorMst on PItems.PV = VendorMst.VendNo
>	join plastpo on pitems.edpno = plastpo.edpno
>Where PItems.edpno = 44181
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform