0% found this document useful (0 votes)
5 views1 page

Assignment-4

sql assignment 4

Uploaded by

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

Assignment-4

sql assignment 4

Uploaded by

vfixit19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, 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 multiplybyten (@num int)


return int
as
begin
return @num*10;
end

select dbo.multiplybyten(20) as answer

--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.

select
case
when 100 < 200 then '100 is less than 200'
when 100 > 200 then '100 is greater then 200'
else '100 is equal to 200'
end

4. Using a case statement, find the status of the amount. Set the status of the
amount as high amount, low amount or medium amount based upon the
condition.

select *,
case
when amount > 200 then "high amount
when amount between 150 and 200 then 'medium amount
else
"less amount'
end as amount_status
from oders

5. Create a user-defined function, to fetch the amount greater than then given
input

create function greaterthen

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy