CAST and ROUND; how to write them together?

It’s really hard to understand how to combine CAST with ROUND in one of the assignments. The task states

  1. Convert the bytes column of the track table to megabytes, and round the results to two decimal places. Alias the result as megabytes.

This is my code, but I don’t know to to include the ROUND function.

SELECT (CAST(bytes AS FLOAT) / 1000000) AS megabytes
  FROM track;

It’s not very thought through to give such an “advanced” assignment without even giving examples how to combine these two functions.

SELECT ROUND((CAST(bytes AS float) / 1000000),2) AS megabytes
FROM track;

1 Like

Thanks a lot! Why is ROUND coming before CAST?
How can you round a variable if the format/type of that variable is not determined first?

@spsshjalpen It is determined first through the order of operations, the () determine that the cast is first.