Sometimes data is stored in a format different from what you need to use. Find out how to transform that data with the CAST command.
- [Instructor] Just because data is stored one way…in the database doesn't mean we can't transform it…into something we need with our query.…Some common functions we'll look at are…changing the case of a string,…converting a value into a different type,…trimming a value, and replacing…a particular string in a field.…Let's start with a basic query like we've seen before.…I'll write SELECT first_name, last_name…FROM people and I'll run that.…
Now let's take a few liberties with the capitalization here.…On the first field, I'll add a function called LOWER…to tell the database to give me…a lowercase representation of the field.…And on the last name I'll add an UPPER function,…again wrapping the field in parentheses,…to transform the text into its uppercase equivalent.…When I run this, keep an eye on the results.…Those are fairly straightforward,…they just take a string and transform it.…
We can also chop up pieces of a string,…say if you need to get the first…five characters of a name for some reason.…And for that we'll use the SUBSTR function,…
- Name the predicate of the following statement: SELECT EyeColor, Age FROM Student WHERE FirstName = 'Tim' ORDER BY LastName ASC;
- Explain what to use to enforce the order in which an expression must be evaluated if the WHERE clause contains multiple expressions to evaluate.
- Identify the best option to join two tables in a database to be able to display data from both.
- List a data type that is not numeric.
- Determine the result of running the following statement on a table containing columns col_1 and col_2:
- INSERT INTO Box (col_1, col_2) VALUES ('A', 'B'), ('A', 'B'), ('A', 'B'), ('A', 'B');
- Determine the best approach of deleting Jon Ramirez (ID 3452) from a Student table.