Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Problem mit Query (https://www.delphipraxis.net/112483-problem-mit-query.html)

mkinzler 22. Apr 2008 14:01

Re: Problem mit Query
 
SQL-Code:
SELECT a.voting_text, count(a.ID) AS ergebnis FROM
(select c.voting_text, MAX(b.voting_id) as ID from data b join data c on c.voting_id = b.voting_id group by b.voting_ip) a
group by a.voting_text;

MaxMara 22. Apr 2008 14:12

Re: Problem mit Query
 
Jetzt funktioniert es schon "besser":
Ich bekomme jedoch für Antwort "Ja" bei ergebnis 2.
Eigentlich sollte es 1 bei Ja und 1 bei Nein sein.

mkinzler 30. Apr 2008 11:21

Re: Problem mit Query
 
So sollte es funktionieren:
SQL-Code:
SELECT a.voting_text, count(a.voting_ip) AS ergebnis FROM
(
   select
       distinct( c.voting_ip), max(c.voting_text) as voting_text
   from
       data b
           join data c on c.voting_ip = b.voting_ip
   group by
       c.voting_ip) a
group by a.voting_text;

MaxMara 30. Apr 2008 13:54

Re: Problem mit Query
 
Danke, hab es jetzt (mit Hilfe eines Freundes) so gelöst:
SQL-Code:
SELECT t1.voting_text, count(*) AS `ergebnis` 
FROM `data` t1 
LEFT JOIN `data` t2 
ON t1.voting_ip = t2.voting_ip
AND t1.voting_date < t2.voting_date
WHERE t2.voting_id IS NULL
GROUP BY t1.voting_text;
Danke an alle Mitdenker :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:23 Uhr.
Seite 4 von 4   « Erste     234   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz