need help answering questih Demonstrate that you did the following (use a SELECT
ID: 3920443 • Letter: N
Question
need help answering questih
Explanation / Answer
-- Assumptions
-- Working in MS SQL SERVER
-- As not database schema provide, I Cretaed a database named TestDB with 2 tables Category & Product
-- Find table create scripts and all other queries in bold
-- Change table name or column name before running according to your schema.
Create Table Category (CategoryId int NOT NULL Primary Key,
Category varchar(32) NOT NULL,
[Description] varchar(2048) NULL);
Create Table Product (ProductId int NOT NULL Primary Key,
Name varchar(64) NOT NULL,
CategoryId int NOT NULL,
Price float NOT NULL,
[ServeType] varchar (32) NULL,
[Description] varchar(2048) NULL);
Select * From Category
Select * From Product
Insert Into category(CategoryId, Category, [Description]) values (1,'Appetizer','Appetiezer Description')
Insert Into category(CategoryId, Category, [Description]) values (2,'Entree','Entree Description')
Insert Into category(CategoryId, Category, [Description]) values (3,'Dessert','Dessert Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (1, 'Bananas Foster', 1, 6.99, 'Hot', 'Bananas Foster Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (2, 'Molten Lava Cake', 1, 5.99, 'Warm', 'Molten Lava Cake Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (3, 'Key Lime Pie', 1, 4.50, 'Cold', 'Key Lime Pie Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (4, 'Ribeye Streak', 2, 16.99, 'Hot', 'Ribeye Streak Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (5, 'Chef Salad', 2, 8.99, 'Cold', 'Chef Salad Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (6, 'Fettuccini Alfredo', 2, 12.99, 'Warm', 'Fettuccini Alfredo Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (7, 'Spinach/Artichoke Dip', 3, 4.99, 'Warm', 'Spinach/Artichoke Dip Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (8, 'Buffalo Wing', 3, 7.99, 'Hold', 'Buffalo Wing Description')
Insert Into product (productId, Name, CategoryId,Price, ServeType, [Description])
values (9, 'Shrimp Cocktail', 3, 8.50, 'Cold', 'Shrimp Cocktail Description')
Update product Set price = (price * 3)/4 Where ServeType = 'Warm';
Select c.categoryID, c.Category, SUBSTRING(c.[Description], 0, CHARINDEX(' ', c.[Description])) 'Desc',
Min(p.price) 'MinPrice', Max(p.price) 'MaxPrice', AVG(p.price) 'AvgPrice'
From category c Inner join product p
on c.categoryID = p.categoryID
Group By c.categoryID, c.Category, c.[Description]
Select Name, ROUND(Price,0,0) 'Price', ServeType, [Description] From Product
Delete From Product Where ServeType = 'Cold'
Select c.category, UPPER(c.[Description]) 'Category Desc', p.Name 'Product Name', UPPER(p.[Description]) 'Product Desc'
From Category c Left Outer Join Product p
on c.categoryID = p.categoryID
Drop Table category;
Drop Table product;
Drop Database TestDB;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.