sql - i want to retrieve data from table where column are same -


i have table named product following data:

maker model type   1232    pc   1233    pc   1276    printer   1298    laptop   1401    printer   1408    printer   1752    laptop b   1121    pc b   1750    laptop c   1321    laptop d   1288    printer d   1433    printer e   1260    pc e   1434    printer e   2112    pc e   2113    pc 

i want retrieve maker , type

condition 1: produce models of same type.
condition 2: number of models exceeds 1.

result desired:

maker   type d       printer 

to maker:

select distinct maker your_table group maker having count(distinct type) = 1 , count(*) > 1 

to maker , type:

select distinct t.maker, t.type your_table t inner join (    select maker    your_table    group maker    having count(distinct type) = 1    , count(*) > 1 ) x on x.maker = t.maker 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -