Note that there are some explanatory texts on larger screens.

plurals
  1. PORounding the numbers in a column in Postgre to the nearest whole number
    primarykey
    data
    text
    <p>Good day. </p> <p>I have multiple tables filled with information about countries. One of these tables contains a population figure for each country; another contains the percentage of speakers of each language.</p> <p>We are to take these two numbers and make a column that lists how many speakers there are for each language... basically, we multiply them. This is simple enough. What isn't simple, however, is displaying them in the manner that we're supposed to. </p> <p>Here's the query I'm using:</p> <pre><code>SELECT country.name AS \"country\", city.name AS \"capital\", country_language.language, (country.population * country_language.percentage) AS \"speakers\" FROM lab2.country, lab2.country_language, lab2.city WHERE country.country_code = country_language.country_code AND city.id = country.capital AND country_language.is_official = true ORDER BY country.name, (country_language.percentage * country.population) DESC; </code></pre> <p>This is what the first resulting table cell is filled with:</p> <pre><code> 1190528034.66797 </code></pre> <p>And here's what it SHOULD be:</p> <pre><code> 11905280 </code></pre> <p>Normally, I'd just make these integers of one flavor or another, and this would solve the problem. But as you see, the numbers I want to round off don't necessarily occur after the decimal point. </p> <p>What should I do to round these off? </p> <p>Here's my website (it's query 5 that you want to select):</p> <p><a href="http://babbage.cs.missouri.edu/~asm3kf/cs3380/lab2/lab2.php" rel="nofollow">http://babbage.cs.missouri.edu/~asm3kf/cs3380/lab2/lab2.php</a></p> <p>and here's the page we're supposed to match:</p> <p><a href="http://babbage.cs.missouri.edu/~klaricm/cs3380/lab2/lab2.php" rel="nofollow">http://babbage.cs.missouri.edu/~klaricm/cs3380/lab2/lab2.php</a></p> <p>You'll see that the inconsistency goes through the entire table. </p> <p>Thanks in advance!</p> <p>EDIT: </p> <p>I updated the site to include the population and percentage numbers. Hopefully, that helps in some way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload