473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Simple SQL help needed

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

TableA
GrpID,IndID,Locked

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*********@yahoo.com

Jul 23 '05 #1
2 1466
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.wisc.edu ...
I'm looking for SQL code to do the following.

TableA
GrpID,IndID,Locked

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*********@yahoo.com

Jul 23 '05 #2
[posted and mailed]

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

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(tinyint, Locked)) = 0

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

st*********@yahoo.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****@sommarskog.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
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...
11
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
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...
4
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...
2
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...
6
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...
18
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...
6
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...
5
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...
30
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.