Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do i place two places after tthe decimal for alias sq_meters? Here is my cod

ID: 3585115 • Letter: H

Question

How do i place two places after tthe decimal for alias sq_meters? Here is my code

SELECT `Name`,`Population`,

FORMAT(`SurfaceArea`,0) AS `Surface area in sq kilometer`,

(`SurfaceArea`/`Population`*1000000) AS `sq_meter`

  

FROM `country`

this is what its suppouse to look like

Namepopulation Surface area in sq KM sq meters per person Brazil China Germany India Japan Nigeria United States 278357000 9,363,520 fter the 33,638.53 170115000 8,547,403 1277558000 9,572,900 82164700 357,022 1013662000 3,287,263 126714000 377,829 111506000 923,768 50,24485 7,493.12 4,345.20 3,242.96 2,981.75 Formatted to 2 places after the decimal point Formatted8,284.47 to 0 places decimal point

Explanation / Answer

SELECT Name,Population,Round(Convert(Numeric(30, 2),SurfaceArea),0) AS "Surface area in sq kilometer",  Round(Convert(Numeric(10, 2), (SurfaceArea/Population*1000000)),2) AS sq_meter FROM country;

Numeric(precision,scale) is used in formatting with precision

Convert() is used to convert the attribute to desired precision

Round() is used for rounding numbers to specific digits

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote