Advertisements
Advertisements
प्रश्न
Consider the following tables:
Table 1: PRODUCTS
This table stores the basic details of the products available in a shop.
| PID | PName | Category |
| 201 | Laptop | Electronics |
| 202 | Chair | Furniture |
| 203 | Desk | Furniture |
| 204 | Smartphone | NULL |
| 205 | Tablet | Electronics |
Table 2: SALES
This table records the number of units sold for each product.
| SaleID | PID | UnitesSold |
| 301 | 201 | 50 |
| 302 | 202 | 100 |
| 303 | 203 | 60 |
| 304 | 204 | 80 |
| 305 | 205 | 70 |
Write SQL queries for the following:
- To delete those records from table
SALESwhoseUnitsSoldis less than 80. - To display names of all products whose category is not known.
- To display the product names along with their corresponding units sold.
कोड लेखन
Advertisements
उत्तर
DELETE FROM SALES WHERE UNITSSOLD < 80;SELECT PNAME FROM PRODUCTS WHERE CATEGORY IS NULL;SELECT P. PNAME, S.UNITSSOLD FROM PRODUCTS P JOIN SALES S ON P.PID = S.PID;
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
