Home » SQL & PL/SQL » SQL & PL/SQL » wats wrong in the query
wats wrong in the query [message #254709] Fri, 27 July 2007 11:31 Go to next message
madhavi122006
Messages: 3
Registered: July 2007
Junior Member
table:
Product(maker, model, type)
Printer(code, model, color, type, price)

Product:

maker model type
A 1232 PC
A 1233 PC
A 1276 Printer
A 1298 Laptop
A 1401 Printer
A 1408 Printer
A 1752 Laptop
B 1121 PC
B 1750 Laptop
C 1321 Laptop
D 1288 Printer
D 1433 Printer
E 1260 PC
E 1434 Printer
E 2111 PC
E 2112 PC

printer

code model color type price
1 1276 n Laser 400.0000
2 1433 y Jet 270.0000
3 1434 y Jet 290.0000
4 1401 n Matrix 150.0000
5 1408 n Matrix 270.0000
6 1288 n Laser 400.0000

Find the makers of the cheapest color printers

i hv written the query like this

select price,maker
from product,printer
where product.model=printer.model
and price=(select min(price) from printer where color='y')

Incorrect.
* Wrong number of records (more by 1)

The results of
Your query:
price maker
270.0000 A
270.0000 D

correct query:
Maker price
D 270.0000


Re: wats wrong in the query [message #254717 is a reply to message #254709] Fri, 27 July 2007 12:18 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
select price,maker
  from product
      ,printer
 where product.model=printer.model
   and printer.color='y'
   and price=(select min(price)
                from printer 
               where color='y')
Try this.
By
Vamsi
Re: wats wrong in the query [message #254719 is a reply to message #254717] Fri, 27 July 2007 12:29 Go to previous messageGo to next message
madhavi122006
Messages: 3
Registered: July 2007
Junior Member
the following error is coming if i run this query

select price,maker
from product
,printer
where product.model=printer.model
and printer.color='y'
and price=(select min(price)
from printer
where color='y')

Incorrect.
Your query produced correct result set on main database, but it failed test on second, checking database.
* Wrong number of records (more by 1)


The result of Your query:
maker price
D 270.0000
Re: wats wrong in the query [message #443214 is a reply to message #254719] Sat, 13 February 2010 13:28 Go to previous messageGo to next message
baubaub
Messages: 2
Registered: February 2010
Junior Member
Hi,

maybe is too late, but the correct answer you can find below:

select distinct p.maker, pr.price from product p
inner join printer pr on
p.model= pr.model and pr.price =(
select min(price) from printer
where color = 'y' ) and pr.color = 'y'


Regards,
Ann
Re: wats wrong in the query [message #443216 is a reply to message #443214] Sat, 13 February 2010 14:54 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes, I don't think anyone is interested in the answer.

Beofre your next post, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code and use code tags.
Use the "Preview Message" button to verify.

Regards
Michel
Re: wats wrong in the query [message #443272 is a reply to message #443216] Sun, 14 February 2010 11:48 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Also, push the "Spell-check Message button" before submitting the reply; doing so, you'd avoid words like Beofre ./fa/2115/0/
icon7.gif  Re: whats wrong in the query [message #443694 is a reply to message #443272] Wed, 17 February 2010 00:52 Go to previous message
baubaub
Messages: 2
Registered: February 2010
Junior Member
Thank you for the information!
Previous Topic: Sending PDF through mail (merged 3)
Next Topic: Missing numbers in a sequence
Goto Forum:
  


Current Time: Sat Dec 03 12:28:49 CST 2016

Total time taken to generate the page: 0.05969 seconds