Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: plz help with a question(corrected an error)

Re: plz help with a question(corrected an error)

From: <oratune_at_aol.com>
Date: Wed, 04 Oct 2000 14:24:51 GMT
Message-ID: <8rfej9$u9m$1@nnrp1.deja.com>

In article <8reu94$fh4$1_at_porthos.nl.uu.net>,   "Frank" <frankbo_at_interaccess.nl> wrote:
> For 1) to be true, the select statement should read
> select price*1.25 ...
> For the where clause...
> Condition 4 can be met (price*0.25=4)
> Condition 3 can be met (man = 25001 or man = 25050).
> 3 and 4 can be met in conjunction:
> where price*.25... AND man= or man=
> condition 2 can be met, but never in combination
> with 3 and 4, as there is an OR, and not an AND
> condition. So the correct answer is b (conditions 3 and 4 are met)
> --
> Frank
> <volk333_at_my-deja.com> schreef in berichtnieuws
> 8re6jl$vne$1_at_nnrp1.deja.com...
> > sorry ,there was an error in my question.
> > i am posting it again.
> >
> >
> >
> > you want to display item prices from inventory with
> > these desired results:
> > 1.the price of each item is increased by 25 persent.
> > 2.the original price must be over $25.
> > 3.the item manufacturer number must be 25001 or 25050.
> > 4.the original price when multiplied by 25% equals $4.
> >
> > you query the database with this SQL statement:
> >
> > SELECT price
> > FROM inventory
> > WHERE price*.25=4.00
> > AND manufacturer_id='25001'
> > OR manufacturer_id='25050' --here i made an error in
 number!
> > OR price>25.00;
> >
> > Which result(s) is true?
> > a.one of the desired results.
> > b.two of the desired results.
> > c.three of the desired results.
> > d.four of the desired results.
> > e.none of the desired results.
> >
> > (explanation)
> > right answer is b.
> > only two of the desired results are achieved when the script is
> > executed. Desired result #3 which specifies that the item
 manufacturer
> > number be 25001 or 25050, and desired result #4 which specifies that
> > the price, when multiplied by 25%, equal $4. The statement does not
> > specify that the price of each item be increased by 25 percent or
 that
> > the price must be over $25 (since the OR logical operator is used
> > instead of the AND operator).
> >
> > .............................................................
> > this answer does not look right to me. what do you think?
> > i think the right answer is e .
> >
> >
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

>
>

Unfortunately the way this query is written does not satisy condition #3 in its entirety:

SELECT price

FROM      inventory
WHERE     price*.25=4.00
AND       manufacturer_id='25001'
OR        manufacturer_id='25050'
OR        price>25.00;

The 'OR' in this statement does not include the previous price condition:

where ...
and ...
and ...

OR ...

The 'OR' starts another set of 'WHERE' criteria so the price condition is not included in the next set of conditions. To include both manufacturer numbers in the initial 'WHERE' parenthesis must be used:

SELECT price

FROM      inventory
WHERE     price*.25=4.00
AND       (manufacturer_id='25001'
           OR manufacturer_id='25050')
OR        price>25.00;

The above query would now satisfy condition #3. The correct answer is still b, however, as there are a total of 5 criteria (the two manufacturer numbers being separate criteria) for the query and 2 of them are met -- the price times 25% equals $4 and the manufacturer number equals 25001.

--
David Fitzjarrell
Oracle Certified DBA


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Oct 04 2000 - 09:24:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US