473,394 Members | 1,774 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,394 software developers and data experts.

Question about using AND in WHERE...

If I have a three column table, will call it AvailClasses

SchoolName, Subject, NumOfClasses
---------------------------------------------------------------
Emil, Biology, 3
Emil, Chemistry, 1
Emil, Calculus, 4
Prestwood, Biology, 2
Prestwood, Chemistry, 4
Prestwood, Calculus, 2
Westhaven, Biology, 1
Westhaven, Chemistry, 2
Westhaven, Calculus, 4

Using this subset of data as an example, I'd like to write a sql query
to return the results of all schools that have at least 2 Bilology
classes and at at least 4 Calculus classes

The query I came up with looks like this... It doesn't work.

SELECT SchoolName FROM AvilClasses WHERE
(Subject = 'Biology' AND NumOfClasses > 1) AND (Subject = 'Calculus'
AND NumOfClasses > 3).

The query above results in an empty set...

Jun 1 '06 #1
2 960

This has already been answered in
microsoft.public.sqlserver.programming

Jun 1 '06 #2

Do not post same question in multiple forums

Madhivanan
JDeats wrote:
If I have a three column table, will call it AvailClasses

SchoolName, Subject, NumOfClasses
---------------------------------------------------------------
Emil, Biology, 3
Emil, Chemistry, 1
Emil, Calculus, 4
Prestwood, Biology, 2
Prestwood, Chemistry, 4
Prestwood, Calculus, 2
Westhaven, Biology, 1
Westhaven, Chemistry, 2
Westhaven, Calculus, 4

Using this subset of data as an example, I'd like to write a sql query
to return the results of all schools that have at least 2 Bilology
classes and at at least 4 Calculus classes

The query I came up with looks like this... It doesn't work.

SELECT SchoolName FROM AvilClasses WHERE
(Subject = 'Biology' AND NumOfClasses > 1) AND (Subject = 'Calculus'
AND NumOfClasses > 3).

The query above results in an empty set...


Jun 2 '06 #3

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

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
55
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's...
13
by: Elaine | last post by:
This has to do with self-joins and includes a running balance problem. Is it possible to do this using SQL alone? Amortization schedule -------------------------- Givens: beginning balance,...
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.