Exercise

Effects of casting

When you cast data from one type to another, information can be lost or changed. See how the casting changes values and practice casting data using the CAST() function and the :: syntax.

SELECT CAST(value AS new_type);

SELECT value::new_type;

Instructions 1/3

undefined XP
  • 1
    • Select profits_change and profits_change cast as integer from fortune500.
    • Look at how the values were converted.
  • 2
    • Compare the results of casting of dividing the integer value 10 by 3 to the result of dividing the numeric value 10 by 3.
  • 3
    • Now cast numbers that appear as text as numeric.
    • Note: 1e3 is scientific notation.