Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*poměrný systém, celorepublikový volební obvod*/
- declare @cenamandatu int;
- declare @rokvoleb int;
- declare @rozdelenomandatu bigint;
- declare @platnychhlasu int;
- select @rokvoleb = 1996;
- select @platnychhlasu = SUM(dbo.results.Votes) from dbo.Results where dbo.results.subjectid is not null and year = @rokvoleb;
- select @cenamandatu = @platnychhlasu / 200 from dbo.Results where dbo.results.subjectid is not null and year = @rokvoleb;
- select @platnychhlasu as "platných hlasů", @cenamandatu as "cena mandátu", @rokvoleb as "rok voleb", @rozdelenomandatu as "rozděleno mandátů (přirozeně)", 200-@rozdelenomandatu as "mandátů zbývá";
- /*rok - počet hlasů celorepublikově - zkratka strany*/
- select sum(dbo.results.votes) as "počet hlasů celorepublikově",
- dbo.Subjects.abbreviation as "zkratka strany",
- (sum(dbo.results.votes)/@cenamandatu) as "počet mandátů",
- (@cenamandatu*(sum(dbo.results.votes)/@cenamandatu)) as "hlasů připočítáno",
- (sum(dbo.results.votes)-(@cenamandatu*(sum(dbo.results.votes)/@cenamandatu))) as "hlasů nepřepočítáno"
- from dbo.Results, dbo.Subjects
- where dbo.results.subjectid = dbo.subjects.subjectid
- and results.year = @rokvoleb
- and results.subjectid is not null
- group by dbo.results.year, dbo.subjects.abbreviation;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement