Question

In: Computer Science

Execute SQL queries to get the countries in which the population has fallen from one year...

Execute SQL queries to get the countries in which the population has fallen from one year to the next, and the years in which it has occurred. Dump the output in the following format:

| country | year |  population | year | population |

| 1 | 2005 | 82500849 | 2006 | 82437995 |

| 1   | 2006 | 82437995 | 2007 |   82314906 |

(...)

And so on.

These are the SQL files:

Tables: pastebin.com/xw0j1NAM

Data: pastebin.com/hnpFT3QR

Solutions

Expert Solution

This will be your SQL query:

SELECT
a.`country`,
a.`year`,
a.`population`,
b.year,
b.population
FROM
`populations` as a inner join populations as b on a.country=b.country
where a.population>b.population and cast(b.year as signed) -cast(a.year as signed)= 1

NOTE:- Please cast year as signed otherwise it will give error " MySQL said: #1690 - BIGINT UNSIGNED value is out of range".

Screenshot of the solution:

I hope, it will be helpful for you.


Related Solutions

Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in...
Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in the WPC Database in MySQL: Display all records from the Employee table for employees working in the “Marketing” department. Display all records from the Employee table for employees working in the “Marketing” department OR “Finance” Department. Display the Last Names of all employees such that each last name appears only once. Display all the attributes for employees whose employee number is less than 10....
For a survey one has a target population and a frame from which the survey sample...
For a survey one has a target population and a frame from which the survey sample is drawn. Describe two ways a frame can differ from the target population
For a survey, one has a target population and a frame from which the sur- vey...
For a survey, one has a target population and a frame from which the sur- vey sample is drawn. Describe two ways a frame can differ from the target population. (c) A local Christchurch organisation wants to find out how people living in Christ- church feel about the Christchurch City Council’s performance. The organi- sation plans to collect responses by surveying people in the central city and several shopping malls throughout Christchurch. Describe the advantages and disadvantages of using this...
Every time I attempt to execute this, I get an inputmismatchexception, which looks like this: Oops!...
Every time I attempt to execute this, I get an inputmismatchexception, which looks like this: Oops! Read Exception: java.util.InputMismatchExceptionInitial input: Input sorted by grade Input sorted selection This is my code. import java.util.*;   import java.io.*; import java.io.PrintStream; public class jack { PrintStream prt = System.out; int n; int i; int j; double grade[]; String name[]; jack() { try { Scanner inf = new Scanner(System.in); n=inf.nextInt(); inf.nextLine(); grade=new double[n]; name = new String[n]; for (int i=0; i<n; i++){ name[i] = inf.next();...
A worker has fallen from a ladder and broken their hip. They will need treatment from...
A worker has fallen from a ladder and broken their hip. They will need treatment from a doctor and rehabilitation. You want to ensure that consultation occurs between the rehabilitation provider, treating doctor, relevant manager and employee. Provide at least three examples. What are some examples of initiatives that result in inevitable consultation? Give at least four examples.
The population of Enchancia is much reduced from its pre-warlevels. Princess Sofia’s decision to execute...
The population of Enchancia is much reduced from its pre-war levels. Princess Sofia’s decision to execute all those peasants who supported James and Amber has greatly diminished the number of workers. Sofia knows that the population will take some time to recover. Without more workers, economic growth can only come if those workers become more productive. Sofia would like you (on pain of death) to provide her with some policy suggestions as to how to achieve this.
Texas has extreme water shortages, which will only get worse as the state population continues to...
Texas has extreme water shortages, which will only get worse as the state population continues to grow. What should the state government do to address this issue
1. A worker has fallen from a ladder and broken their hip. They will need treatment...
1. A worker has fallen from a ladder and broken their hip. They will need treatment from a doctor and rehabilitation. You want to ensure that consultation occurs between the rehabilitation provider, treating doctor, relevant manager and employee. Provide at least three examples. 2. What are some examples of initiatives that result in inevitable consultation? Give at least four examples. 3. List the steps an agent could take when establishing a rehabilitation program with the employee.
Currently, aggregate supply has fallen because of the corona virus. Which of the three determinants of...
Currently, aggregate supply has fallen because of the corona virus. Which of the three determinants of supply mentioned above is associated with the drop of aggregate supply?
A client has fallen in part due to low blood pressure. Which of the medications listed...
A client has fallen in part due to low blood pressure. Which of the medications listed below may have contributed to the drop in his blood pressure? Answers: metolazone, a thiazide agent digoxin, an inotropic agent simvastatin, an anti-lipemic agent clopidogrel, an anti-platelet agent nifedipine, a calcium channel blocker for angina candesartan, an ARB (angiotensin receptor blocker)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT