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...
-
The following are various changes in audit circumstances. Audit Circumstance 1. Analytical procedures indicated a significant slowing in accounts receivable turnover. 2. The client entered into sales...
-
For binary observations, consider the model (x) = 1/2 + (1/)tan 1 ( + x). Which distribution has cdf of this form? Explain when a GLM using this curve might be more appropriate than logistic...
-
Describe project quality management (PQM) in terms of planning for quality, quality assurance, and quality control to continuously improve the projects products and supporting processes. AppendixLO1
-
On February 1, the Miro Company needs to purchase some office equipment. The company is presently short of cash and expects to be short for several months. The company treasurer has indicated that he...
-
ns Selected information about income statement accounts for the Reed Company is presented below the company's fiscal year ends on December 31). 2021 2020 Sales revenue Cost of goods sold...
-
Robinson Products Company has two service departments (S1 and S2) and two production departments (P1 and P2). The distribution of each service departments efforts (in percentages) to the other...
-
(a)How many commuters take both the bus and the subway? commuters (b)How many commuters take only the subway? commuter A survey was completed of individuals who were currently on the Zone diet (Z),...
-
In the circuit of Fig. 4-51 write two loop equations using I 1 and I 2 . Then find the currents and node voltages. A 3A ( 4 3 V 792 B +1 D w 392 12 C
-
The capacitor in the circuit shown in Fig. 7-37 has initial charge Q 0 = 800 C, with polarity as indicated. If the switch is closed at t = 0, obtain the current and charge, for t > 0. 100 V (+ 10 4 F
-
A gift shop sells 400 boxes of scented candles a year. The ordering cost is \($60\) for scented candles, and holding cost is \($24\) per box per year. What is the economic order size for scented...
-
Kay Vickery is angry with Gene Libby. He is behind schedule developing supporting material for tomorrows capital budget committee meeting. When she approached him about his apparent lackadaisical...
-
Tharpe Painting Company is considering whether to purchase a new spray paint machine that costs \($3,000\) . The machine is expected to save labor, increasing net income by \($450\) per year. The...
-
E5-18A (similar to) Question Help At December 31, 2018. Get Away Travel has an Accounts Receivable balance of $95.000. Allowance for Uncollectible Account has a credit balance of 5900 before the year...
-
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 is the present value annuity factor of $1.00 at a discount rate of 10% for 15 years? a. 5.0 b. 7.6 c. 10.0 d. 13.9
-
Donald has $100 today. He is aware of TWO investment opportunities: (a) invest $50 and expect to receive $55 in one years time, or (b) invest $100 today and expect to receive $120 in one years time....
-
What quarterly payment is necessary to accumulate $3.75 million over 20 years if the annual interest rate is 4% compounded quarterly? Assume payments are made at the end of each quarter. a. $733.0 b....
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App