Entwickler-Ecke

Datenbanken - SQL ANweisung Hilfe benötigt


Bronstein - Fr 21.11.08 17:26
Titel: SQL ANweisung Hilfe benötigt
Hallo,
ich benötige ein spzielle SQL-Anweisung, falls dies ünerhaupt funktioniert. Hier mal ein paar Beispiel Daten meiner Tabelle PRUEFUNG

PREUFUNGSTART|PREUFUNGENDE|PRUEFPROGRAMM
20.11.2008 06:00:00|20.11.2008 06:00:30|Programm1
20.11.2008 06:02:00|20.11.2008 06:02:30|Programm1
20.11.2008 06:08:00|20.11.2008 06:08:30|Programm1
20.11.2008 12:00:00|20.11.2008 12:00:30|Programm2
20.11.2008 12:02:00|20.11.2008 12:02:30|Programm2
20.11.2008 12:08:00|20.11.2008 12:08:30|Programm2
20.11.2008 16:00:00|20.11.2008 16:00:30|Programm1
20.11.2008 16:02:00|20.11.2008 16:02:30|Programm1
20.11.2008 16:08:00|20.11.2008 16:08:30|Programm1
20.11.2008 16:20:00|20.11.2008 16:20:30|Programm1

Also Ergebnis der SQL hätte ich gerne folgende
START|ENDE|PRUEFPROGRAMM|ANZAHLPRUEFUNGEN
20.11.2008 06:00:00|20.11.2008 06:08:30|Programm1|3
20.11.2008 12:00:00|20.11.2008 06:08:30|Programm2|3
20.11.2008 16:00:00|20.11.2008 16:20:30|Programm1|4

Geht sowas?


matze - Fr 21.11.08 21:57

Ja das geht. Ich weiß nicht,welche Datenbank du einsetzt aber dieSyntaxdürfte in etwa so lauten:

SQL-Anweisung
1:
SELECT *, count() FROM tabelle GROUP BY prüfung                    


Xentar - Fr 21.11.08 22:25

Damit würde die erste und zweite Gruppe "Programm1" aber zusammengefasst werden, zu 7.
Wie man das weg bekommt.. kA.. garnicht?


Bronstein - Fr 21.11.08 22:29

Genau das ist mein Problem, dass dann die sieben al Ergebis kommt!

Muss ich wohl über eine Schleife machen und jeden DS einzeln prüfen!


WPs - Sa 22.11.08 11:16

Hi,
ich gehe mal davon aus, dass mit deiner Endzeit fuer programm2 12:08:30 und nicht 6:08:3012 gemeint ist.
Unter der Voraussetzung,dass es nur 1(eine) Unterbrechung gibt- sonst wird es halt immer komplizierter- versuche mal dieses


SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
select min(a) as anfang,max(b) as ende,p as programm,
count(p) as anzahl
from timest
where b<
(select min(a) from timest where p=2)
group by p
union
select min(a),max(b),p,
count(p) 
from timest
where p=2
group by p
union
select min(a),max(b),p,
count(p) 
from timest
where 
a>
(select max(a) from timest where p=2)
group by p


Werner


Bronstein - Sa 29.11.08 09:34

Danke!

Jetzt hab ich nochmal fast das gleiche Problem:

PREUFUNGSTART|PRUEFPROGRAMM
20.11.2008 06:00:00|Programm1
20.11.2008 06:02:00|Programm1
20.11.2008 06:08:30|Programm1
20.11.2008 12:00:00|Programm2
20.11.2008 12:02:00|Programm2
20.11.2008 12:08:30|Programm2
20.11.2008 16:00:00|Programm1
20.11.2008 16:02:00|Programm1
20.11.2008 16:08:00|Programm1
20.11.2008 16:20:30|Programm1

Also Ergebnis der SQL hätte ich gerne folgende
START|ENDE|PRUEFPROGRAMM|ANZAHLPRUEFUNGEN
20.11.2008 06:00:00|20.11.2008 06:08:30|Programm1|3
20.11.2008 12:00:00|20.11.2008 12:08:30|Programm2|3
20.11.2008 16:00:00|20.11.2008 16:20:30|Programm1|4


UGrohne - Sa 29.11.08 09:52

user profile iconBronstein hat folgendes geschrieben Zum zitierten Posting springen:
Danke!

Jetzt hab ich nochmal fast das gleiche Problem:

Und was hast Du aus dem obigen Statement bisher gemacht, um dieses fast gleiche Problem zu lösen?