KnowledgeBoat Logo

Informatics Practices

Given the table LIBRARY :

NoTitleAuthorTypePubQtyPrice
1Data StructureLipschutzDSMcGraw4217
2Computer StudiesFrenchFNDGalgotia275
3Advanced PascalSchildtPROGMcGraw4350
4Dbase dummiesPalmerDBMSPustakM5130
5Mastering C + +GurewichPROGBPB3295
6Guide NetworkFreedNETZPress3200
7Mastering FoxproSeigalDBMSBPB2135
8DOS guideNortonOSPHI3175
9Basic for BeginnersMortonPROGBPB340
10Mastering WindowCowartOSBPB1225

Give the output of following SQL commands on the basis of table Library.

(i) SELECT UPPER(Title) FROM Library WHERE Price < 150 ;

(ii) SELECT CONCAT(Author, Type) FROM Library WHERE Qty < 3 ;

(iii) SELECT MOD(Qty, 4) FROM Library ;

SQL Queries

3 Likes

Answer

(i) SELECT UPPER(Title) FROM Library WHERE Price < 150 ;

+---------------------+
| UPPER(Title)        |
+---------------------+
| COMPUTER STUDIES    |
| DBASE DUMMIES       |
| MASTERING FOXPRO    |
| BASIC FOR BEGINNERS |
+---------------------+

Working

The SQL query SELECT UPPER(Title) FROM Library WHERE Price < 150; returns the uppercase version of the Title column for all rows in the LIBRARY table where the Price column is less than 150.

(ii) SELECT CONCAT(Author, Type) FROM Library WHERE Qty < 3 ;

+----------------------+
| CONCAT(Author, Type) |
+----------------------+
| FrenchFND            |
| SeigalDBMS           |
| CowartOS             |
+----------------------+

Working

The query SELECT CONCAT(Author, Type) FROM Library WHERE Qty < 3; concatenates the Author and Type columns using the CONCAT() function from the LIBRARY table for books that have a quantity less than 3.

(iii) SELECT MOD(Qty, 4) FROM Library ;

+-------------+
| MOD(Qty, 4) |
+-------------+
|           0 |
|           2 |
|           0 |
|           1 |
|           3 |
|           3 |
|           2 |
|           3 |
|           3 |
|           1 |
+-------------+

Working

The SQL query SELECT MOD(Qty, 4) FROM Library; calculates the remainder when each book's quantity (Qty) in the LIBRARY table is divided by 4 using the MOD() function.

Answered By

3 Likes


Related Questions