Autor Beitrag
juergen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Fr 16.04.04 14:31 
Hallo
wie kann ich die anzeigereihenfoge in einer gruppe beeinflussen ?
Bspl:
teilenummer:teil1 datum:01.01.01
teilenummer:teil1 datum:01.01.02
teilenummer:teil1 datum:01.01.03
teilenummer:teil2 datum:01.01.01
teilenummer:teil2 datum:01.01.02

mit select * from ... group by teilenummer soll nun das folgende angezeigt werden:

teilenummer:teil1 datum:01.01.03
teilenummer:teil2 datum:01.01.02

also jedes teil mit aktuellstem datum

geht das ???
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Fr 16.04.04 14:58 
So:

ausblenden Quelltext
1:
GROUP BY feldname, feldname2 ORDER BY feldname3					


Geht aber net in allen Datenbanken.

_________________
Ha! Es compiliert! Wir können ausliefern!
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Fr 16.04.04 15:18 
das problem ist, das mir immer das zuerst eingegebene Teil angezeigt wird

teilenummer:teil1 datum:01.01.01
teilenummer:teil2 datum:01.01.01
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Fr 16.04.04 15:39 
Was für ne Datenbank?

Muss funktionieren mit dem Order-BY. Wenn Du die Reihenfolge andersrum haben willst nimm ORDER BY feldname DESC

_________________
Ha! Es compiliert! Wir können ausliefern!
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Fr 16.04.04 15:46 
MySQL Datenbank

ausblenden Quelltext
1:
select teilenr, freigabestand  from projekt  group by teilenr order by freigabestand desc/asc					


es wird nur die anzeige sortiert nicht aber innerhalb der gruppe
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 19.04.04 08:23 
Hallo,

folgendermaßen könnte es klappen:

ausblenden Quelltext
1:
2:
3:
4:
SELECT teilenr, freigabestand 
FROM projekt  
GROUP BY teilenr, freigabestand  
ORDER BY teilenr, freigabestand

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Nanakai
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Mo 19.04.04 09:09 
Hallo Juergen,

versuch es mal mit

ausblenden Quelltext
1:
2:
3:
4:
SELECT Teilenr, MAX(Freigabestand) 
FROM Projekt 
GROUP BY Teilenr 
ORDER BY MAX(Freigabestand) DESC


Grüße

Nana


[EDIT: Spaltennamen angepasst]
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 19.04.04 09:28 
@Nanakai: Das funktioniert bei mySQL definitiv nicht.

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Mo 19.04.04 10:36 
@ Nana: bei Deiner Syntax bekomme ich folgende Fehlermeldung
Invalid use of group function

@ Smiegel: wenn ich nach teilenr und freigabestand gruppiere werden alle angezeigt, nicht nur das aktuelle Teil

hat noch jemand ne Idee ??

juergen
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mo 19.04.04 11:56 
Hallo,

ich hätte Deine Frage aufmerksamer lesen sollen. Dein Problem müsste dann folgendermaßen zu lösen sein:
ausblenden Quelltext
1:
2:
3:
4:
SELECT teilenr, MAX(freigabestand)
FROM projekt  
GROUP BY teilenr
ORDER BY teilenr, freigabestand

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Mo 19.04.04 13:03 
@ smiegel

jetzt passiert folgendes:

teilenr und letzter freigabestand werden richtig angezeigt
ABER
es sollen natürlich auch weitere felder des aktuellen teils angezeigt werden.
diese zuordnung stimmt allerdings nicht !
alle anderen felder (z.b. projektnr, zeichnungsnummer etc.) werden wieder vom zuerst eingegebenen teil angzeigt.

Bspl:
projekntnr:1 teilenummer:teil1 datum:01.01.01
projekntnr:2 teilenummer:teil1 datum:01.01.02
projekntnr:3 teilenummer:teil1 datum:01.01.03
projekntnr:4 teilenummer:teil2 datum:01.01.01
projekntnr:5 teilenummer:teil2 datum:01.01.02

Mit:
ausblenden Quelltext
1:
2:
3:
4:
SELECT projektnr, teilenr, MAX(freigabestand) 
FROM projekt  
GROUP BY teilenr 
ORDER BY teilenr, freigabestand


wird angezeigt:

projekntnr:1 teilenummer:teil1 max(datum):01.01.03
projekntnr:4 teilenummer:teil2 max(datum):01.01.02


Das möchte ich natürlich nicht.

Sondern:

projekntnr:3 teilenummer:teil1 datum:01.01.03
projekntnr:5 teilenummer:teil2 datum:01.01.02

Gibts noch Ideen ?