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...
-
LF Ltd wishes to manufacture a new product. The company is evaluating two mutually exclusive machines, the Reclo and the Bunger. Each machine is expected to have a working life of four years, and is...
-
During late 2016, Ski Lifters commenced a new business in the Alpine region to rent ski gear to tourists. A budget has been prepared for the coming financial year. Prepare a brief report to...
-
To exchange heat between four streams with \(\Delta T_{\text {min }}=20^{\circ} \mathrm{C}\), the HEN in Figure 11.61 is proposed. Determine whether the network has the minimum utility requirements....
-
The Deer Valley Farm produces a natural organic fertilizer, which it sells mostly to gardeners and homeowners. The annual demand for fertilizer is 220,000 pounds. The farm is able to produce 305,000...
-
The following events occurred for Favata Company: a. Received $13,000 cash from owners and issued stock to them. b. Borrowed $10,000 cash from a bank and signed a note due later this year. c. Bought...
-
Arrow Hospitality prepares adjustments monthly and showed the following at September 30, 2023: Additional information available for the month ended September 30, 2023: a. Interest of $162 had accrued...
-
You are in charge of the manufacture of cylinders of compressed gas at a small company. Your company president would like to offer a 4.00 L cylinder containing 500 g of chlorine in the new catalog....
-
What are the five steps in the strategic control process?
-
Why do stakeholders in the same organization often have different goals? Would it not be best if they shared the same goals? Explain.
-
Top-down change efforts __________. A. are not always successful B. can be augmented through employee participation C. are not necessarily more effective than bottom-up efforts D. all of the above
-
The systematic collection and analysis of information about relevant macroenvironmental trends is known as __________. A. strategic planning B. strategic management C. environmental scanning D. none...
-
The value chain is an analytical technique for identifying organizational opportunities and threats. True of False
-
Edlie Accessories (EA) makes travel bags, both for sale under their own label ("Branded") and for other resellers to put their label on the bags ("Private-Label"). The bags sold through the two...
-
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...
-
What are a manager's resources?
-
What are the three levels of management?
-
Joe Maddon has been the manager of the Chicago Cubs since 2015. In his first year, he exceeded the expectations of most analysts and fans by leading the team to an appearance in the National League...
Study smarter with the SolutionInn App