Weather Observation Station 2

Sort by

recency

|

1507 Discussions

|

  • + 0 comments

    SELECT ROUND(SUM(LAT_N), 2) AS lat, ROUND(SUM(LONG_W), 2) AS lon FROM STATION;

  • + 0 comments

    SELECT CAST(ROUND(SUM(LAT_N), 2) AS DECIMAL(10,2)), CAST(ROUND(SUM(LONG_W), 2) AS DECIMAL(10,2)) FROM STATION;

  • + 0 comments

    select cast(Round(sum(lat_n),2) as decimal(38,2)) as [lat], cast(Round(sum(long_W),2) as decimal(38,2)) as [lon] from station

    /* Only the round doasn't get rid of the trailing zeros. So you have to cast as decimal then (38, 2). The 38 is for precision, this means you can have a total of 38 digits in total (left and right of the decimal point). The 2 is for scale, this means the number of digits that are gonna be stored agter the decimal point.

    */

  • + 0 comments

    SELECT CAST(ROUND(SUM(LAT_N), 2) AS DECIMAL(10,2)), CAST(ROUND(SUM(LONG_W), 2) AS DECIMAL(10,2)) FROM STATION;

    Successful submission on DB2 server => calculate the sum -> round() which rounds to 2 decimal places but includes trailing zeros as well -> cast it to Decimal(10,2) to remove any trailing zeros after 2 decimal places

  • + 0 comments

    Why this query is not working in MY SQL Server -

    SELECT ROUND(SUM(LAT_N), 2), ROUND(SUM(LONG_W), 2) FROM STATION;