Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[volby] přeběhlíci #212

Open
kokes opened this issue Aug 10, 2022 · 0 comments
Open

[volby] přeběhlíci #212

kokes opened this issue Aug 10, 2022 · 0 comments

Comments

@kokes
Copy link
Owner

kokes commented Aug 10, 2022

Hlavní problémy:

  1. Nemáme to view v_kandidati nikde automatizované
  2. V tom view chybí obvody u některých voleb (př. komunálních)
WITH nejnovejsi AS (
	SELECT
		*
	FROM
		volby.v_kandidati
	WHERE
		volby = 'ep'
		AND datum = (SELECT max(datum) FROM volby.v_kandidati WHERE volby = 'ep')
), opakovani as (
	SELECT
		vk.*, nj.datum as nejnovejsi_datum
	FROM
		volby.v_kandidati vk
		inner join nejnovejsi nj using(jmeno, volby)
		where 1=1
			and abs((vk.datum - vk.vek*365) - (nj.datum - nj.vek*365)) < 365
)

select
	jmeno, string_agg(distinct strana, ', ') strany,
	max(case when datum = nejnovejsi_datum then strana else null end) strana_nyni
from opakovani
group by jmeno
having count(distinct strana) > 1
limit 1000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant