Solved

Return records not matching criteria using group by

Posted on 2008-10-06
1
162 Views
Last Modified: 2012-05-05
I have a table that contains text type information for a given case.  There can be 1 or more text type for a given case.  I am trying to write a query that will return only those case numbers that do not have a text_type of resolution for any of the text types for a given case

 Here is some sample  data

Case_id     Text_Type_Seq   Text_Type        
1                1                           Notes
1                2                           Notes
1                3                           Resolution
2                1                           Notes
2                2                           Notes
2                3                           Notes
2                4                           Notes
3                1                           Notes
3                2                           Notes
4                1                           Notes
4                2                           Resolution


Using the sample data above:

The query should only return

Case_ID
2
3

Since case 1 and 4 have a text type of resolution
0
Comment
Question by:johnnyg123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 22650132
Select distinct Case_ID
From MyTable T1
Where Not Exists (Select Case_ID From MyTable T2 Where T1.Case_ID = T2.Case_ID And T2.Text_type = 'Resolution')
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question