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...
-
If objects of weights x and w1 are suspended from the balance in Figure 13(A), the cross-beam is horizontal if bx = aw1. If the lengths a and b are known, we may use this equation to determine an...
-
In Fig. 30.11, suppose that = 60.0 V, R = 240 and L = 0.160 H. Initially there is no current in the circuit. Switch S2 is left open, and switch S1 is closed. (a) Just after S1 is closed, what are the...
-
Why did the Federal Reserve and the government intervene to bail out AIG?
-
Ross Co., Westerfield, Inc., and Jordan Company announced a new agreement to market their respective products in China on July 18 (7/18), February 12 (2/12), and October 7 (10/7), respectively. Given...
-
Two movers apply forces to a 487 kg piano. If one mover pushes the piano with a force of 250 N, and the other pulls with a force of 160 N, what is the acceleration of the piano?
-
A company conducts a consumer survey with questions about home ownership (OwnHome: Yes/No), car ownership (OwnCar: Yes/No), annual household spending on food (Food), and annual household spending on...
-
The collection of a $2200 account after the 1 percent discount period expires will result in a A. debit to Cash for $2200. B. debit to Accounts Receivable for $2200. C. debit to Sales Discounts for...
-
In Problem 23, what is the cost of equity after recapitalization? What is the WACC? What are the implications for the firms capital structure decision? Problem 23, Bruce & Co. expects its EBIT to be...
-
When Beacon Computers entered insolvency, it had the following balance sheet information: Assuming there are no legal fees associated with the bankruptcy, as trustee, what distribution of liquidating...
-
Star plc, a prominent consumer products firm, is debating whether or not to convert its all-equity capital structure to one that is 40 per cent debt. Currently there are 2,000 shares outstanding and...
-
It is believed that the following data fit the model Test this claim at the 5% significance level. - 0
-
ABC AG and XYZ AG are identical firms in all respects except for their capital structure. ABC is all equity financed with NKr600,000 in equity shares. XYZ uses both shares and perpetual debt; its...
-
Leaders often need to deal with ambiguous and competing inputs on complex topics. The results of their decisions impact lives and careers of various stakeholder groups. At times, quality seems to...
-
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...
-
Validate Eq. (4.20) and Eq. (4.25). Data From Equation (4.20) Data From Equation (4.25) t= 12 n dr. n
-
Derive Eq. (4.24). Data From Equation (4.24) sin =1- noro cos Bo nr
-
Using Snell's law (i.e., \(n_{o} r_{o} \cos \theta_{0}=n_{1} r_{1} \cos \theta_{1}\) ), show that \[ \left(\sin \left(\frac{\theta_{1}}{2}ight)ight)^{2}=\frac{r_{o}}{2 r_{1}}\left[2\left(\sin...
Study smarter with the SolutionInn App