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

Assignment 4a

Uploaded by

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

Assignment 4a

Uploaded by

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

SELECT MIN(Amount) AS Minimum_Amount, MAX(Amount) AS Maximum_Amount,

AVG(Amount) AS Average_Amount
FROM Cust_Order;

-- 2. Create a user-defined function which will multiply the given number with
10

CREATE FUNCTION Mult_by_10 (@Amount FLOAT, @Factor FLOAT)


RETURNS INT
AS
;

-- 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 'LESS'
WHEN 100=200 THEN 'EQUAL'
ELSE 'MORE'
END
AS Check_the_Number;

-- 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< 2000 THEN 'LOW'
WHEN Amount BETWEEN 2000 AND 4000 THEN 'MEDIUM'
ELSE 'HIGH'
END
AS Amt_Comparision
FROM Cust_Order;

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


given input.

CREATE FUNCTION Expensive_Products (@Amount FLOAT)


RETURNS TABLE
AS
RETURN (SELECT * FROM Cust_Order WHERE AMOUNT>@Amount);

SELECT * FROM dbo.Expensive_Products (2500);

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