Truncate
Use trunc()
to examine the distributions of attributes of the Fortune 500 companies.
Remember that trunc()
truncates numbers by replacing lower place value digits with zeros:
trunc(value_to_truncate, places_to_truncate)
Negative values for places_to_truncate
indicate digits to the left of the decimal to replace, while positive values indicate digits to the right of the decimal to keep.
This exercise is part of the course
Exploratory Data Analysis in SQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Truncate employees
SELECT ___(___, ___) AS employee_bin,
-- Count number of companies with each truncated value
___
FROM fortune500
-- Use alias to group
GROUP BY ___
-- Use alias to order
ORDER BY ___;