Photo AI

Button [2.1.1 - List of roses] Display all the details of the plants in the Rose category in the tblPlants table - NSC Information Technology - Question 2 - 2019 - Paper 1

Question icon

Question 2

Button-[2.1.1---List-of-roses]---Display-all-the-details-of-the-plants-in-the-Rose-category-in-the-tblPlants-table-NSC Information Technology-Question 2-2019-Paper 1.png

Button [2.1.1 - List of roses] Display all the details of the plants in the Rose category in the tblPlants table. Example of output of the first five records: ... show full transcript

Worked Solution & Example Answer:Button [2.1.1 - List of roses] Display all the details of the plants in the Rose category in the tblPlants table - NSC Information Technology - Question 2 - 2019 - Paper 1

Step 1

Button [2.1.1 - List of roses]

96%

114 rated

Answer

To display all details of the plants in the Rose category from the tblPlants table, use the following SQL query:

SELECT * FROM tblPlants WHERE Category = 'Rose';

This query selects all fields from the tblPlants table where the Category is 'Rose'.

Step 2

Button [2.1.2 - Pink roses and flowers]

99%

104 rated

Answer

To retrieve the PlantCode, Category, Colour, and SizeOfPot fields for all plants in the Flower and Rose categories, use:

SELECT PlantCode, Category, Colour, SizeOfPot FROM tblPlants WHERE (Category = 'ROSE' OR Category = 'FLOWER') AND Colour LIKE '%Pink%';

This ensures that we get records from both categories that include the colour Pink.

Step 3

Button [2.1.3 - Average price per category]

96%

101 rated

Answer

To calculate the average price of plants per category, the following SQL can be used:

SELECT Category, FORMAT(AVG(Price), 'Currency') AS AveragePrice FROM tblPlants GROUP BY Category;

This retrieves the average price formatted as currency for each category.

Step 4

Button [2.1.4 - Display information for invoice number F2]

98%

120 rated

Answer

To display information for invoice number F2, execute:

SELECT InvoiceNum, Description, NumberOrdered FROM tblPlants, tblOrders WHERE tblOrders.PlantCode = tblPlants.PlantCode AND InvoiceNum = 'F2';

This SQL query joins both tables based on the PlantCode and filters by InvoiceNum.

Step 5

Button [2.1.5 - Update items delivered]

97%

117 rated

Answer

To update the NumberDelivered field to match the NumberOrdered for a specific item, use:

UPDATE tblOrders SET NumberDelivered = NumberOrdered WHERE ItemNum = 'QuotedStr(ItemNum)';

This SQL command correctly updates the records according to the provided ItemNum.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;