Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help limiting This Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00852388
Message ID:
00852391
Vues:
7
This message has been marked as the solution to the initial question of the thread.
Kirk,
Try to add following condition
 ... 
    AND (SELECT COUNT(*) 
         FROM dbo.meetproc mp 
         WHERE dbo.meetings.meetingnumber = mp.meetingnumber
	 AND (mp.coperid = @tiSurgeonID) 
         and  (mp.procid=@tiProcID)) = 1 
...
>Once again, this query performs exactly as written....but i failed to properly understand a requirement. That is that when I select the data from meetings & meetproc, I only want the meetings that have only one child record in the meetproc table where the meetproc.procid=@tiProcID. Meetproc is a child table to meetings. Most the time, there is only one child record for each meeting record, BUT sometimes there are more. I want to exclude the ones that have more than one child record in meetproc, even if that meetproc record has the right @tiProcID.
>
>Thanks for any help
>
>
>select avg(det.ortime) as AvgORMinutes,
>    (Select isnull(cleanup,0) from coProc where coProc.ProcID=det.procid) as Cleanup,
>    (Select isnull(setup,0) from coProc where coProc.ProcID=det.procid) as Setup
>	from (select top 20
> 	        dbo.meetings.enteror, dbo.meetings.exitor,
>	        datediff(mi,enteror,exitor) as ORTime,meetproc.procid
>	      FROM dbo.meetings INNER JOIN
>		   dbo.meetproc ON dbo.meetings.meetingnumber = dbo.meetproc.meetingnumber
>	      WHERE  (dbo.meetproc.coperid = @tiSurgeonID) AND (dbo.meetings.iscompleted = 1)
>		  and  (dbo.meetproc.procid=@tiProcID)
>  	     ORDER by endtime desc )det
>group by det.procid
>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform