Given a database of the results of an election, find the number of seats won by...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a database of the results of an election, find the number of seats won by each party. There are some rules to going about this: • There are many constituencies in a state and many candidates who are contesting the election from each constituency. • Each candidate belongs to a party. • The candidate with the maximum number of votes in a given constituency wins for that constituency. The output should be in the following format: Party Seats_won The ordering should be in the order of seats won in descending order. Schema There are 2 tables: Candidates and Results. Candidates Name Туре Description id INTEGER It is the primary key. gender STRING The gender of the candidate. age INTEGER Age of the candidate. party STRING The party to which the candidate belongs to. Results Name Туре Description constituency_id INTEGER It is the constituency to which the candidate is contesting from. candidate_id INTEGER It is the primary key. votes INTEGER The number of votes won by the candidate. v Sample Data Tables Candidates id gender age party 1 M 55 Democratic M 51 Democratic 3 F 62 Democratic M 60 Republic F 61 Republic F 58 Republic Results constituency_id candidate_id votes 1 1 847529 1 4 283409 2 293841 5 394385 3 3 429084 3 6 303890 Expected Output: Democratic 2 Republic 1 2. 2. 2. 4. Given a database of the results of an election, find the number of seats won by each party. There are some rules to going about this: • There are many constituencies in a state and many candidates who are contesting the election from each constituency. • Each candidate belongs to a party. • The candidate with the maximum number of votes in a given constituency wins for that constituency. The output should be in the following format: Party Seats_won The ordering should be in the order of seats won in descending order. Schema There are 2 tables: Candidates and Results. Candidates Name Туре Description id INTEGER It is the primary key. gender STRING The gender of the candidate. age INTEGER Age of the candidate. party STRING The party to which the candidate belongs to. Results Name Туре Description constituency_id INTEGER It is the constituency to which the candidate is contesting from. candidate_id INTEGER It is the primary key. votes INTEGER The number of votes won by the candidate. v Sample Data Tables Candidates id gender age party 1 M 55 Democratic M 51 Democratic 3 F 62 Democratic M 60 Republic F 61 Republic F 58 Republic Results constituency_id candidate_id votes 1 1 847529 1 4 283409 2 293841 5 394385 3 3 429084 3 6 303890 Expected Output: Democratic 2 Republic 1 2. 2. 2. 4.
Expert Answer:
Answer rating: 100% (QA)
Short Summary Provided the Creation Insertion and Selection queries performed on tables Candidates a... View the full answer
Related Book For
Statistical Reasoning for Everyday Life
ISBN: 978-0321817624
4th edition
Authors: Jeff Bennett, Bill Briggs, Mario F. Triola
Posted Date:
Students also viewed these mathematics questions
-
An election is being held to fill three seats on the board of directors of a firm in which you hold stock. The company has 7,600 shares outstanding. If the election is conducted under cumulative...
-
An election is being held to fill three seats on the board of directors of a firm in which you hold stock. The company has 17,400 shares outstanding. If the election is conducted under cumulative...
-
An election is being held to fill three seats on the board of directors of a firm in which you hold stock. The company has 19,600 shares outstanding. If the election is conducted under cumulative...
-
a. Consider the effect of population growth on the allocation on the dynamic efficient allocation of a depletable resource across time. Suppose we have two versions of the two-period model, discussed...
-
Suppose there are three molecules, and that the probability of remaining is thought to be p = 0.6. In a sample of 80 cells, we find 10 with 0 molecules, 20 with 1 molecule, 30 with 2 molecules, and...
-
Consider the following information for a typical investment project with a service life of five years: What interest rate is used in the project-balance calculation? Cash Flow Project Balance ...
-
What roles might more recent analysis activities, such as data mining, predictive statistical analyses, and operational experiments, play in increasing organizational effectiveness?
-
Pendray Scientific Inc. manufactures electronic products, with two operating divisions, the GPS Systems and Communication Systems Divisions. Condensed divisional income statements, which involve no...
-
Write pseudocode to implement the flowchart depicted in the following figure to calculate the square root of any given positive number a. -Make sure the proper indentation is included to make the...
-
W&S Partners has just won the January 31, 2026, audit for Cloud 9. As a part of the risk assessment phase for the new audit, the audit team needs to gain an understanding of Cloud 9's structure and...
-
Brand: Starbucks What do you think that customers truly want from this brand? What makes this brand "relevant"? Are there any environmental variables that they are capitalizing on for their success?
-
Quantitative analysis is a. a logical approach to decision making. b. a rational approach to decision making. c. a scientific approach to decision making. d. all of the above.
-
Which of the following is an example of a continuous distribution? a. the binomial distribution. b. the exponential distribution. c. the Poisson distribution. d. the Z distribution.
-
Which of the following phases is part of an inventory system? a. planning b. forecasting c. control d. feedback and revisions e. all of the above
-
Using LP to determine the most economical and effective nutritional programme for patients is an application known as a. the transportation problem. b. the product mix. c. the diet problem. d. the...
-
Enounce all the assumptions required for formulating a linear programming problem. You should be able to mention and synthetically describe at least seven of them.
-
Problem 2. Recall from Calculus II that the nth right-hand approximation R, of the integral of a function [a, b] R is given by f(x)dx = Arf (a + iAx) where Ar. Write a MATLAB script which computes...
-
In Exercises find dy/dx by implicit differentiation. xy - y = x
-
One of the authors compiled a list of actual high temperatures and the corresponding list of three-day-forecast high temperatures. The difference for each day was then found by subtracting the...
-
Table 5.1 includes standard scores and percentiles. Can a z-score be a negative value? Can a percentile be a negative value? Explain.
-
a. Construct a frequency table for the weights of regular Pepsi. Use bins of 0.8130-0.8179 0.8180-0.8229 0.8230-0.8279 0.8280-0.8329 0.8330-0.8379 0.8380-0.8429 b. Construct a frequency table for the...
-
Explain why budgets are important to all organizations. Expand this discussion by illustrating how different types of budgets are used.
-
Compare and contrast licensure and credentialing.
-
Describe the steps in attaining state licensure for nurses.
Study smarter with the SolutionInn App