top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

A table named fruit has the attributes "ID", "Fruit name" and "Basket No":

+1 vote
789 views

|ID | Fruit Name | Basket No|
|1 |Apple |1 |
|2 |Banana |2 |
|3 |Orange |1 |
|1 |Apple |2 |
|2 |Banana |3 |
|3 |Orange |2 |
|4 |Mango |2 |
|5 |Grapes |1 |
|1 |Apple |3 |​

question 1: Find the basket number which have more than 2 fruits.
question 2: Find the basket number which contain orange.
question 3: Find the fruits which are present in more than one basket.

posted Jun 15, 2015 by Shivaranjini

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

question 1:find the basket number which have more than 2 fruits.

SELECT   basket_no
FROM     baskets
GROUP BY basket_no
HAVING   COUNT(*) > 2

question 2:find the basket number which contain orange.

SELECT DISTINCT basket_no
FROM   baskets
WHERE  fruit_name = 'Orange'

question 3:Find the fruits which are present in more than one basket.

SELECT   fruit_name
FROM     baskets
GROUP BY fruit_name
HAVING   COUNT(*) > 1
answer Jun 15, 2015 by Manikandan J
...