The table contains manufacturer and the…
The table contains manufacturer and the model name of Cars
(version column should be ignored). Find those manufacturers who have more than 1 type of model(eg. MARUTI has ALTO, DZIRE and SWIFT) and show the output as

manufacturer model

Desired output (The results Order not is not mandatory)

MARUTI SWIFT
MARUTI ALTO
MARUTI DZIRE
HYUNDAI i10
HYUNDAI i20

CREATE TABLE car_model(manufacturer VARCHAR(30), model VARCHAR(10),version int);
INSERT INTO car_model VALUES(‘MARUTI’,’SWIFT’,1);
INSERT INTO car_model VALUES(‘MARUTI’,’SWIFT’,2);
INSERT INTO car_model VALUES(‘MARUTI’,’SWIFT’,3);
INSERT INTO car_model VALUES(‘MARUTI’,’ALTO’,1);
INSERT INTO car_model VALUES(‘MARUTI’,’ALTO’,2);
INSERT INTO car_model VALUES(‘MARUTI’,’ALTO’,3);
INSERT INTO car_model VALUES(‘MARUTI’,’DZIRE’,1);
INSERT INTO car_model VALUES(‘HYUNDAI’,’i10′,1);
INSERT INTO car_model VALUES(‘HYUNDAI’,’i10′,2);
INSERT INTO car_model VALUES(‘HYUNDAI’,’i20′,1);
INSERT INTO car_model VALUES(‘HYUNDAI’,’i10′,2);
INSERT INTO car_model VALUES(‘FERRARI’,’ACER’,1);
INSERT INTO car_model VALUES(‘FERRARI’,’ACER’,1);
INSERT INTO car_model VALUES(‘VOLKSWAGON’,’POLO’,1);
INSERT INTO car_model VALUES(‘VOLKSWAGON’,’POLO’,1);

Part 2:

In the table, how would you retrieve the unique values for the model without using the DISTINCT keyword?



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *