Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Return records not matching criteria using group by

Posted on 2008-10-06
1
Medium Priority
?
164 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 2000 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

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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…

715 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