Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
659 views

SQL Module 4 Assignment

The document contains 3 SQL queries: 1) Finds the min, max, and average values from the amounts column in the orders table; 2) Creates a user-defined function that multiplies a given number by 10; 3) Uses a CASE statement to check if 100 is less than, greater than, or equal to 200 and returns the corresponding text value.

Uploaded by

Isha Karnalkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
659 views

SQL Module 4 Assignment

The document contains 3 SQL queries: 1) Finds the min, max, and average values from the amounts column in the orders table; 2) Creates a user-defined function that multiplies a given number by 10; 3) Uses a CASE statement to check if 100 is less than, greater than, or equal to 200 and returns the corresponding text value.

Uploaded by

Isha Karnalkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

-1.

Use the inbuilt functions and find the minimum, maximum and average amount from the
orders table
select min(amount) as min_amount, max(amount) as max_amount,avg(amount) as avg_amount
from orders

--2.Create a user-defined function, which will multiply the given number with 10
create function mul_ten(@num int)
returns int
as begin
return(@num * 10)
end

select dbo.mul_ten(10)

--3.Use the case statement to check if 100 is less than 200, greater than 200 or
equal to 2oo and print the corresponding value
select
case
when 100<200 then '100 is less than 200'
when 100>200 then '100 is greater than 200'
else '100 is equal to 200'
end

You might also like