1.

Pranay, who is an Indian, created a table named "Friends" to store his friend's detail. Table "Friends" is shown below. Write commands in SQL for (i) to (iv) and output for (v) to (vii).S_No.NameAgeCityCountryEmail_ID1Alice14WashingtonUSA[email protected]2Charles12CopenhagenDenmark[email protected]3Angle16ChicagoUSA[email protected]4Jasmine15SydneyAustralia[email protected]5Raj14New DelhiIndia[email protected]6Jette13NykobingDenmark[email protected]7Alexender15MelbourneAustraliaNull8Shashank16BangaloreIndiaNull(i) To display list of all foreigner friends.(ii) To list name, city and country in descending order of age.(iii) To count how many friends have email id on gmail.(iv) To list name and city of those friends who don't have an email id.(v) Select name, country from friends where age>12 and name like 'A%';(vi) Select ucase(concat(name," * ",city)) from friends where country like 'Denmark';(vii) Select mid(name,1,4) as "UID" from friends where country like 'USA';

Answer»

(i) Select Name From Friends Where Country Not Like "lndra";

(ii) Select Name, City, Country From Friends Order By Age Desc;

(iii) Select Count(*) From Friends Where Email_id like "% gmail%";

(iv) Select Name, City,  From Friends Where Email_id is null;

                          OUTPUT

NameAGECountry
Alice14USA
Angel16USA
Alexender15Austrailia

(vi)

Ucase (concat (name, "", city)
Charles *Copenhagen
Jettle*Nykobing

(vii)

uid
Alic
Angle



Discussion

No Comment Found

Related InterviewSolutions