Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

Chapter 6:Advanced Retrieval Operations > CASE Expressions - Pg. 156

156 Chapter 6: Advanced Retrieval Operations The EXTRACT operator pulls out a part of a date and/or time. It has the following general format: EXTRACT (datetime_field FROM datetime_value) EXTRACT For example, the query SELECT EXTRACT (YEAR FROM CURRENT_DATE); returns the current year. In addition to the datetime fields you saw earlier in this sec- tion, EXTRACT also can provide the day of the week (DOW) and the day of the year (DOY). CASE Expressions The SQL CASE expression, much like a CASE in a general purpose programming language, allows a SQL statement to pick from among a variety of actions based on the truth of logical expressions. Like arithmetic and string operations, the