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.
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: 9780321817624
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...

As CEO of your company, youve been going over your financial statements and have noticed something disturbing. You perform a horizontal analysis and find that sales have been increasing at a rate of...

Do you agree that U.S. taxpayers should protect U.S. sugar farmers against less expensive imports?

Serendipity Sound, Inc. manufactures and sells compact discs. Price and cost data are as follows: Selling price per unit (package of two CDs) ...............$25.00 Variable costs per unit: Direct...

The pH of a 0.100 M acetic acid solution is 2.88. Calculate K a .

The XYZ Corporation was duly organized on July 10. Its certificate of incorporation provides for total authorized capital of $1 million, consisting of ten thousand shares of common stock with a par...

Consider the following schedule S. read (T1. x), write(T2, x), write(T1, x), read(T3, x), commit (T1), commit(T2), commit (T3) Questions: (a) (8 marks) briefly describe the concepts of lost update,...

The 2014T6 aluminium rod has a diameter of 30 mm and supports the load shown. Determine the displacement of end A with respect to end E. Neglect the size of the couplings. 8 kN 2 kN 6 kN 4 kNY 2m...

You are shown the following Markowitz frontier and Capital Market Line, from a UK perspective, when combining UK stocks with German stocks. UK stocks have an expected return of 4% and a standard...

Using CVP analysis build a graph based on the latest income statement. Calculate the following figures for two years based on the income statement: (4 points) Contribution Margin Ratio Level of...

1. Suppose in a faculty meeting, the department chair, Portia asked all of the faculty to propose a new course and send the proposals to her. Professor Edgar, doesn't care if anyone sees his...

We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this c++ code. The user enters a number with characters of 2 to 8. If the number is a two digit number...

Write up the following accounts clearly showing the amount for the income statement selling expenses travelling expenses rental income club members fees The following data was obtained from the books...

a) Explain Bellman Ford algorithm. b) Differentiate between Bellman Ford and Dijikstra's Algorithm. c) Solve the graph step by step taking A as source using Bellman Ford algorithm. 2 13 10 d) Explain...

The shape of Mercury can be approximated by a sphere with a diameter of 4880 kilometers. Find the surface area and the volume of Mercury. For surface area, round your answer to the nearest tenth of a...

Explain the term global capital markets. This chapter primarily discusses global equity markets. What other types of financial instruments are traded in these markets? How important are global...

One of the authors compiled a list of actual high temperatures and the corresponding list of threedayforecast high temperatures. The difference for each day was then found by subtracting the...

Table 5.1 includes standard scores and percentiles. Can a zscore 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.81300.8179 0.81800.8229 0.82300.8279 0.82800.8329 0.83300.8379 0.83800.8429 b. Construct a frequency table for the...

The following transactions took place for Smart Solutions Inc. Required: Prepare the journal entries that Smart Solutions Inc. would record for the above transactions.

E Recently, a new social network site, Facepage, was founded. Given the current trends, the managers of Facepage are convinced that this will be the new hype in the near future. When new users want...

Consider this rule: An employee of a department can never earn more than the manager of the department. This is an example of a: a. Syntactical integrity rule. b. Semantical integrity rule.