T-SQL in One Hour a Day, Sams Teach Yourself by Alison Balter
Author:Alison Balter [Balter, Alison]
Language: eng
Format: azw3, pdf
Publisher: Pearson Education
Published: 2015-10-23T04:00:00+00:00
FIGURE 13.14 An example of executing a stored procedure that includes the RETURN statement.
FIGURE 13.15 An example of executing the same stored procedure with a different value for the month of the current date.
Working with the CASE Statement
Most developers use the CASE statement to compare a result from a SQL statement against a set of simple responses. The CASE statement returns the appropriate value. The CASE statement looks like this:
Click here to view code image
CASE InputExpression
WHEN WhenExpression THEN ResultExpression
[...n]
[ELSE ElseResultExpression]
END
Here’s an example of this use of a case statement:
Click here to view code image
SELECT SalesOrderID, ShipDate,
CASE ShipMethodID
WHEN 1 THEN 'UPS'
WHEN 3 THEN 'FedEx'
WHEN 5 THEN 'U.S. Mail'
END AS Shipper,
Freight FROM Sales.SalesOrderHeader
WHERE ShipDate BETWEEN '1/1/13' AND '2/28/13'
AND Freight <= 50
The expression selects the SalesOrderID, ShipDate, and Freight fields from the Sales.SalesOrderHeader table. The CASE statement evaluates the contents of the ShipMethodID field. It returns an appropriate string depending on the value in the ShipMethodID field. Figure 13.16 illustrates this example.
Download
T-SQL in One Hour a Day, Sams Teach Yourself by Alison Balter.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6790)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6765)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6652)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6438)
Driving Data Quality with Data Contracts by Andrew Jones(6379)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6140)
Learning SQL by Alan Beaulieu(6004)
Weapons of Math Destruction by Cathy O'Neil(5795)
Big Data Analysis with Python by Ivan Marin(5389)
Data Engineering with dbt by Roberto Zagni(4393)
Solidity Programming Essentials by Ritesh Modi(4043)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3901)
Pandas Cookbook by Theodore Petrou(3601)
Blockchain Basics by Daniel Drescher(3305)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2914)
Feature Store for Machine Learning by Jayanth Kumar M J(2819)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2802)
Mastering Python for Finance by Unknown(2748)
