473,404 Members | 2,213 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,404 software developers and data experts.

Sql Sub query "any"

Hi i am using oracle sql developer and am making a sub query for a question.

The question states: "Find Name of patients who have been treated by Dr Brian or who have had an Extended Consultation.

The following is the relational schema for the database:
Patient (PatientID, FamilyName, GivenName)
Doctor (ProviderNo, Name)
Item (ItemNo, Description, Fee)
Account (AccountNo, ProviderNo, PatientID, Date)
AccountLine (AccountNo, ItemNo)

Where:
- Description Contains the value "Extended Consultation" among other values.
- ProviderNo is unique number for each doctor.

As only attributes from the patient table are used i gather you only need to do a subquery using an "ANY" statement to outline the condition, where only one needs to be true.
So i tired this query:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Select familyname, givenname
  3. from dtoohey.Patient
  4. where patient.patientID in (select patientID 
  5.                          from dtoohey.account 
  6.                          where account.providerNo any (select providerNO 
  7.                                               from dtoohey.doctor 
  8.                                               where doctor.name = 'Dr Brian' 
  9.                                               and account.accountno any (select accountNo 
  10.                                                                     from dtoohey.accountline   
  11.                                                                     where accountline.itemNo In (select itemNo 
  12.                                                                     from dtoohey.item 
  13.                                                                     where description = 'Extended Consultation'))));
  14.  
However i get the error message:
Error at Command Line:5 Column:50
Error report:
SQL Error: ORA-00920: invalid relational operator
00920. 00000 - "invalid relational operator"

It also comes up with an error message for the second relational operator.
This statement works fine with IN however i dont think that producers the right result.
Althought i am still learning sql, if there is a better structured query comapred to this one please let me know, or how to remove the syntax error. Thanks:)
Sep 2 '07 #1
3 3122
debasisdas
8,127 Expert 4TB
you need to modify your code to

=ANY( ....)

the rest is OK.
Sep 3 '07 #2
Ahh i see thank you :)
Sep 3 '07 #3
debasisdas
8,127 Expert 4TB
you are most welcome.

happy programming.
Sep 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: teddysnips | last post by:
I am studying for the MSCE/MCDBA exam 70-229. In the book I am using ("MCSA/MCSE/MCDBA Self-Paced Training Kit: Microsoft SQL Server 2000 Database Design and Implementation Exam 70-229, Second...
6
by: wyhang | last post by:
I want a implementation just like the "join" in the unix shell, I googled the web and found nothing. Any suggestion will be highly appreciated, thank you~
0
by: Omkar Singh | last post by:
I am using XmlSerialization and XmlDeserialization for making soap Body part. Then I am making sopa-header and other part of soap envelope manually. At last joining all part to get complete soap...
4
by: Greg Stark | last post by:
I find myself wishing I had a syntax "LIKE ANY (array)". I don't see much value in the = ANY, = ALL, <> ANY, <> ALL syntax since they're equivalent more or less to IN and NOT IN. But it could be...
2
by: AA Arens | last post by:
When I place a record serch utility (vos the button placement wizzrd), I discovered that the Match setting is "Whole Field" by default. How to make "Any Part Of Field" default?
60
by: K. G. Suarez | last post by:
Hello everyone. I am new to programming and my uncle gave me a copy of "C For Dummies 2nd Edition". I am up to chapter 9 right now. He probably saw me struggling with "The C Programming...
2
by: Lance Geeck | last post by:
I have many items that I lifted off from Microsoft's website several years ago. These samples were in VB6. I now want to convert an application to VB.NET. I am getting an error that says "As Any...
2
by: babakandme | last post by:
Hi everybody:D I've a string that contains the name of a class. Some members told that I can use """Stringizing Operator (#)""", but the problem is here, that I have the string, & I want...
2
by: Peter Duniho | last post by:
On Fri, 18 Jul 2008 10:41:23 -0700, jmDesktop <needin4mation@gmail.com> wrote: Well, that's an interesting example, if for no other reason than that the DirectShow video capture stuff is a...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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,...
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.