Assignment : 3
Task 1 :Use the inbuilt functions and find the minimum, maximum and average amount from the orders table
select min(amount) as Min_Amount from Orders
select max(amount) as Max_Amount from Orders
select avg(amount) as Avg_Amount from Orders
Task 2 :Create a user-defined function, which will multiply the given number with 10
create function Multiply
(@param int)
returns int
as
begin
return @param * 10
end
select [dbo].[Multiply] (19) as ResultMulti
Task 3 : Use the case statement to check if 100 is less than 200, greater than 200 or equal to 200 and print the corresponding value.
declare @input int
set @input=100
select
case
when @input<200 then 'input is less than 200'
when @input>200 then 'input is greater than 200'
else 'input is equal to 200'
end as result