MySQL Forums
Forum List  »  German

Datenbankabfrage
Posted by: Wilhelm Putz
Date: October 23, 2015 08:23AM

Folgendes Problem:

Tabelle sieht so aus:

ID fid datum stunde1 stunde2 stunde3 stunde4 stunde5

1 1 1.1.2010 0 2 1 3 2
2 1 20.1.2010 1 1 2 5 0
3 1 11.1.2012 0 2 0 0 0
4 2 1.2.2011 5 1 0 1 3
5 3 10.3.2010 1 5 4 5 8
6 3 15.5.2012 0 1 2 3 4
7 4 4.3.2010 8 0 1 2 1
8 4 15.6.2013 8 5 0 0 0
9 5 6.3.2014 1 1 1 1 1

Folgendes Ergebnis ist gewünscht:


Der letzte Datumseintrag pro fid, die Zeilensumme der einzelen Spalten und
die Anzahl der Spalten die einen Eintrag ungleich 0 haben.

Ergebnis wäre:

fid höchstes Datumm Zeilensumme(stunde1-5) Anz Spalten ungleich 0
1 11.1.2012 2 1
2 1.2.2011 10 4
3 15.5.2012 10 4
4 15.6.2013 13 2
5 6.3.2014 5 5


mit:

select sum(stunde1-5)
from...
where ...
group by fid

bekomme ich die Zeilensumme, allerding hat max(datum) in der Abfrage nicht funktioniert und auch beim Rest stehe ich an.
Danke für eure Hilfe

Options: ReplyQuote


Subject
Views
Written By
Posted
Datenbankabfrage
1549
October 23, 2015 08:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.