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: | Pl... 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, the SQL query would be:

SELECT * FROM tblPlants WHERE Category = 'Rose';

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

Step 2

Button [2.1.2 - Pink roses and flowers]

99%

104 rated

Answer

To display the required fields for plants in both the Rose and Flower categories, you can use:

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

This query selects the relevant columns where the category is either 'ROSE' or 'FLOWER' and the colour contains 'Pink'.

Step 3

Button [2.1.3 - Average price per category]

96%

101 rated

Answer

To calculate the average price of all plants grouped by category, the following SQL statement can be used:

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

This query computes the average price for each category and formats the result in currency.

Step 4

Button [2.1.4 - Display information for invoice number F2]

98%

120 rated

Answer

To display invoice information for invoice number F2, the SQL query will look like this:

SELECT InvoiceNum, Description, NumberOrdered
FROM tblOrders
WHERE InvoiceNum = 'F2';

This retrieves the specified fields from the tblOrders table for the invoice number F2.

Step 5

Button [2.1.5 - Update items delivered]

97%

117 rated

Answer

To update the NumDelivered field to match NumOrdered, you can use the following SQL statement:

UPDATE tblOrders
SET NumberDelivered = NumberOrdered
WHERE ItemNum = ?;

In this case, ? should be replaced with the actual item number variable from the user input.

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

;