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 retrieve all the details of plants in the Rose category from the tblPlants table, you can use the following SQL query:

SELECT * FROM tblPlants WHERE Category = 'Rose';

This statement selects all fields from the tblPlants table where the Category is equal to 'Rose.'

Step 2

Button [2.1.2 - Pink roses and flowers]

99%

104 rated

Answer

To display plant information for those in the Flower and Rose categories with a specific colour (Pink), the SQL query can be written as:

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

This ensures that we get all plants belonging to either the Rose or Flower category while specifically filtering for the Pink colour.

Step 3

Button [2.1.3 - Average price per category]

96%

101 rated

Answer

To calculate the average price for each plant category and format it in currency, you can use the following SQL statement:

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

This query computes the average price for plants grouped by their category.

Step 4

Button [2.1.4 - Display information for invoice number F2]

98%

120 rated

Answer

To display invoice information for the specified number (F2), the appropriate SQL query is:

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

This retrieves details from both tables based on the matching plant code and filters for the invoice number F2.

Step 5

Button [2.1.5 - Update items delivered]

97%

117 rated

Answer

To update the number of items delivered in the tblOrders table, the SQL statement would be:

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

This modifies the NumberDelivered field to match NumberOrdered where the ItemNum is equal to a certain variable.

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

;