java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.sql.xml
changeset 108 f74a9fc683da
child 109 374ec52b5b69
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.sql.xml	Tue Apr 27 17:13:23 2010 +0200
     1.3 @@ -0,0 +1,25 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
     1.6 +<properties>
     1.7 +    <entry key="HLASOVANI_INSERT">
     1.8 +	INSERT INTO hlasovani
     1.9 +	(podnik, hlas, ip_adresa)
    1.10 +	VALUES (:podnik, :hlas, :ip_adresa);
    1.11 +    </entry>
    1.12 +    <entry key="HLASOVANI_SELECT">
    1.13 +	<!--
    1.14 +	    Poznámka k přetypování int4(count(*)):
    1.15 +	    maximum je: 2 147 483 647 (tolik hlasů snad mít nikdy nebudeme :-)
    1.16 +	-->
    1.17 +	SELECT	hlas,
    1.18 +	    int4(count(*))
    1.19 +	FROM (
    1.20 +	    SELECT DISTINCT ON (ip_adresa)
    1.21 +		hlas
    1.22 +	    FROM hlasovani
    1.23 +	    WHERE podnik = :podnik
    1.24 +	    ORDER BY ip_adresa, id DESC
    1.25 +	) AS hlasy
    1.26 +	GROUP BY hlas;
    1.27 +    </entry>
    1.28 +</properties>
    1.29 \ No newline at end of file