Jump to content

How to...


mATOK

Recommended Posts

Hi, I'm not sure how to explain what I want in my query but I will do my best

 

I have a table that contains a key field, Ids, group ids and group names

 

I have multiple rows for the same id.

 

I want to find the IDs where data like below is present, i.e. more than 1 row contains a grouptypeid set to 1 and there is at minimum one row that contains a GroupTypeId set to 6

 

Key Field| ID  |groupID |groupType | name

 

2312316 | 61232 | 2 | 1 | blahblah

2312317 | 61232 | 3 | 1 | lahblahb

2312318 | 61232 | 4 | 1 | ahblahbl

2312319 | 61232 | 6 | 6 | 123456

2312320 | 61232 | 7 | 6 | 234567

 

 

 

 

Link to comment
Share on other sites

select distinct requestid

 

from request_group

 

where grouptypeid = 6

 

and requestid in

 

(select requestid

 

from request_group

 

where grouptypeid = 1

 

group by requestid, grouptypeid

 

having count(*) > 1)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.