Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Doubt in SQL


Message #1 by Gowri Shankar <shankargo@y...> on Thu, 24 Oct 2002 10:36:40 -0700 (PDT)
Here is the solution,
step 1.
create table items(product varchar(15),price money,brand varchar(15))
Step2
Insert the data
Issue the query as

select * from items a
where exists ( select 1
             from   items b
             where a.product = b.product
             and   a.price =b.price
             and   a.brand = b.brand
             group by product, price, brand 
              having count(1) > 1  )

Regards,
Qadri



> Hi,

I have a table

Table 1:

Product  Price   Brand
----------------------
Shoe     2000    Nike
Shoe     3000    addidas
shoe     2000    Nike
Camera   5000    Canon
Camera   5000    Canon
Camera   4000    Olympus

I need to check whether the product , price and brand are same and then
report only those value. 
Output
Product  Price   Brand
----------------------
Shoe     2000    Nike
Shoe     2000    Nike
Camera   5000    Canon
Camera   5000    Canon

There will be n number of products like this. I tried using 'group by'.
But i was not able to get the result properly.
Can anyone help me in this.

Regards,
Shankar

__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

  Return to Index