Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: just to do ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 11055 of 11517
Post > Topic >>

Re: just to do a select

by Iain Sharp <iains@[EMAIL PROTECTED] > May 19, 2008 at 08:56 AM

On Wed, 26 Dec 2007 04:27:05 -0800 (PST), "harry9katz@[EMAIL PROTECTED]
"
<harry9katz@[EMAIL PROTECTED]
> wrote:

>On Dec 26, 10:23 am, noumian <n.nou...@[EMAIL PROTECTED]
> wrote:
>> hello, i cant find how to make this select :
>>
>> here is what i have : 2 tables
>> Incident(incident_id,incident_name)
>> action(action_id,incident_id,action_name,dept_id)
>>
>> what i want?
>> i would like to find all those incident which have all their action
>> with dept_id=3.
>>
>> how can we do this?
>
>SELECT     *, Incident.incident_name
>FROM         action LEFT OUTER JOIN
>                      Incident ON action.incident_id =
>Incident.incident_id
>WHERE     (action.dept_id = 3)

That selects where some of the action took place in department 3. 

Try 

select incident.incident_id, incident_name
from incident inner join action on incident.incident_id =
action.incident_id
group by incident.incident_id, incident_name
where max(dept_id) = 3 and min(dept_id) =3

This presumes dept_id is always filled in.
 




 1 Posts in Topic:
Re: just to do a select
Iain Sharp <iains@[EMA  2008-05-19 08:56:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 0:43:57 CST 2008.