SQL practice: Numbers and Type Casting

Chapter 21 · 8 questions · included in full access

  1. Question 1 · easy

    Show each product's price rounded to a whole number.

    Solve it in your browser
  2. Question 2 · easy

    Show the average product price rounded to 2 decimals.

    Solve it in your browser
  3. Question 3 · medium

    Work out what percent of all products each category represents. (Mind the integer division.)

    Solve it in your browser
  4. Question 4 · medium

    Show each product's profit margin as a percentage of its selling price, rounded to 1 decimal.

    Solve it in your browser
  5. Question 5 · medium

    In Postgres, dividing two integers (7 / 2) returns 3. Write a query that divides 7 by 2 to get the decimal result 3.5.

    Solve it in your browser
  6. Question 6 · medium

    Show each order line's total, rounded, alongside the same total rounded up to the next whole number.

    Solve it in your browser
  7. Question 7 · hard

    Calculate what percentage of orders are Delivered.

    Solve it in your browser
  8. Question 8 · hard

    Show each category's average unit price rounded to 2 decimals. It fails with 'function round(double precision, integer) does not exist'. Fix it.

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing