473,802 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple SQL help needed

I'm looking for SQL code to do the following.

TableA
GrpID,IndID,Loc ked

50001,10001,0
50001,10002,0

50002,10003,0
50002,10004,1
50002,10005,0

50003,10006,0
50003,10007,0
50003,10008,0

50004,10009,0
50004,10010,0
50004,10011,1
50004,10012,1
I would like to return GrpID's where All IndID have Locked = 0

Recordset
GrpID

50001
50003

Email me at the following:

st*********@yah oo.com

Jul 23 '05 #1
2 1490
SELECT GrpID
FROM TableA
GROUP BY GrpID
HAVING MAX(Locked)=0

Mr Tea

"Gregory S Moy" <mo*@epi.ophth. wisc.edu> wrote in message
news:MP******** *************** *@news.doit.wis c.edu...
I'm looking for SQL code to do the following.

TableA
GrpID,IndID,Loc ked

50001,10001,0
50001,10002,0

50002,10003,0
50002,10004,1
50002,10005,0

50003,10006,0
50003,10007,0
50003,10008,0

50004,10009,0
50004,10010,0
50004,10011,1
50004,10012,1
I would like to return GrpID's where All IndID have Locked = 0

Recordset
GrpID

50001
50003

Email me at the following:

st*********@yah oo.com

Jul 23 '05 #2
[posted and mailed]

Gregory S Moy (mo*@epi.ophth. wisc.edu) writes:
TableA
GrpID,IndID,Loc ked

50001,10001,0
50001,10002,0

50002,10003,0
50002,10004,1
50002,10005,0

50003,10006,0
50003,10007,0
50003,10008,0

50004,10009,0
50004,10010,0
50004,10011,1
50004,10012,1
I would like to return GrpID's where All IndID have Locked = 0
SELECT GrpID
FROM TableA
GROUP BY GrpID
HAVING MAX(convert(tin yint, Locked)) = 0

This query is untested, as you did not include CREATE TABLE and
INSERT statements.
Email me at the following:

st*********@yah oo.com


Had you included that address as a Reply-To in the header, this is
where the courtsey copy would have gone.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3986
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without problems. I want to be able to distribute this program using py2exe, but I am having some problems. I am using a simple setup.py like in the documentation for the py2exe tool and everything compiles ok, except that when I run the exe, I get an...
11
2719
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
4
1511
by: GGarramuno | last post by:
I have a program that expects its input in a specific format. Mainly, it expects floating-point values to be formatted in the form: 1.32 1. 3. 3.2345 In case you missed it, all floating point values have a period, even when they are round numbers. This is a somewhat similar behavior to the %g flag of
4
7092
by: bob lambert | last post by:
Help I am trying to deploy to another pc a vb.net std 2002 windows form application. I am confused. I created a project - windows form I built form, compiled and debugged. I created a deployment project (myproj installer) I added my windows app to the installer under myproj installer properties, I set bootstrapper
2
5666
by: news reader | last post by:
Hi, Does anoone of you know if there is already a simple application doing something like this. I would enhance / tune the missing features, but would like to avoid to start from scratch or to start from something, that has far too many features and is difficult to setup.
6
9428
by: sathyashrayan | last post by:
Dear group, Following is a exercise from a book called "Oreilly's practical C programming". I just wanted to do a couple of C programming exercise. I do have K and R book, but let me try some simple one. Exercise 4-2: Write a program to print a block E using asterisks (*), where the E has a height of seven characters
18
1926
by: Bob Cummings | last post by:
Not sure if this is the correct place or not. Anyhow in school we were taught that when trying to calculate the efficiency of an algorithm to focus on something called FLOPs or Floating Point operations and disregard all integer operations. My question is this. I am writing a simulation for animal dispersement through large landscapes. We are loading data from several different files to simulate the environment the animals will be...
6
1595
by: sandy | last post by:
I think I just need a pair of eyes here... I can't see what I am doing wrong. I am creating a new Class for an assignment, Class File. I have a header and a cpp file. When I try to write the constructor in the cpp file it tells me: File.cpp new types may not be defined in a return type File.cpp return type specification for constructor invalid
5
2542
by: aaragon | last post by:
Hi everyone, I wrote a very simple function to try to understand the casting of variables in C++. The function is function foo() { std::vector<inttest(100); randomize(test); unsigned long x = 0;
30
3552
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.