April 2026
Beginner
493 pages
23h 2m
English
In this section, we’ll get familiar with some supplementary functions to help you empower and simplify your queries. Mind you that they are not exactly syntactic sugar; instead, they may fulfill critical roles in the right scenarios.
Data type conversion is a natural part of nearly all programming platforms, and DQL is no exception. We use the CAST keyword to convert a value from one data type to another. The basic syntax is as in Listing 7.165.
CAST(expression AS target_type);
Listing 7.165 Syntax for CAST Function
Some simple CAST operations are demonstrated in Listing 7.166.
SELECT CAST ('123' AS INTEGER) AS v1, CAST(CURRENT_DATE AS VARCHAR(10)) AS v2, CAST(99 AS VARCHAR(2)) AS v3;
Listing ...
Read now
Unlock full access