Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SubQuery more than 1 value, help ?

Author  Topic 

andrewcw
Posting Yak Master

133 Posts

Posted - 2006-04-27 : 22:46:32
Earlier today I received excellent help on putting together a complex join and query. THANKS AGAIN !

I need also to constrain the proc_fkeys with a where clauses but the revised - query ( the red is what was added and broke it ) gives an error - the subquery cannot contain more than 1 value. I think the query can be written correctly, where do I limit the PROC_FKEY values ???


SELECT c.LineNumber, mystats.CUSTOMER, mystats.PROC_FKey, mystats.inTotal
FROM dbo.CustomerLineNumber AS c INNER JOIN
(SELECT CUSTOMER, PROC_FKey, COUNT(BoolCtr) AS inTotal
FROM (SELECT CSB_FKey, PROC_FKey, LEFT(CSB_FKey, 5) AS CUSTOMER, PassStatus, 1 AS BoolCtr
FROM dbo.TestDynamic
WHERE (PassStatus <> 'PASS') AND (TestTime >= '20060121') AND (TestTime < '20060221')


and ( PROC_FKEY=
(SELECT PROC_KEY
FROM dbo.TestProcKey
WHERE (ModelEnum = 0) )
)


) AS t
GROUP BY CUSTOMER, PROC_FKey) AS mystats ON c.Customer = mystats.CUSTOMER
ORDER BY mystats.inTotal DESC



andrewcw

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-27 : 22:48:55
changed to PROC_FKEY IN



KH


Go to Top of Page

andrewcw
Posting Yak Master

133 Posts

Posted - 2006-04-27 : 22:55:42
( PROC_FKEY=( to ( PROC_FKEY in (

IT works - Thank you KhTan that was really fast and worked :) !


andrewcw
Go to Top of Page
   

- Advertisement -