Autor Beitrag
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 10.06.03 17:37 
Hi,

kann mir jemand verraten wie ich dashier:

ausblenden Quelltext
1:
2:
3:
SELECT Leisung, COUNT(Leistung) 
FROM Leisungstabelle 
GROUP BY Leisung


Absteigend nach der Leistung sortieren kann??? :nixweiss:

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Di 10.06.03 17:43 
ORDER BY Leistung DESC
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 10.06.03 17:52 
mhh....

der sortiert aber falsch :)

ich hab das mit dem GROUP BY ja gemacht um zu zählen wie oft welche Leistung vorkommt...

Wenn jetzt die Leistungen:
L1 3x
L2 5x
L3 1x
vorkommen, dann sortiert er es so:

L3, L2, L1

und nicht:
L2, L1, L3
(so brauch ich es)

weißt du wie ich's mein? :)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Di 10.06.03 17:55 
Also genau umgekehrt?
ORDER BY Leistung ASC
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 10.06.03 18:10 
Neee....

ich will das er zählt wie oft welche Leistung vorkommt, und mir dann dannach sortiert anzeigt "Leistung 3 kam am häufigsten dran, Leistung 2 an 2ter stelle" etc.. :)

_________________
Aya
I aim for my endless dreams and I know they will come true!
mars
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 238

Debian Woody, Win 2000, Win XP
D7 Ent, Kylix 3
BeitragVerfasst: Di 10.06.03 18:39 
Bin nicht ganz sicher...:
ausblenden Quelltext
1:
2:
3:
4:
SELECT Leistung, COUNT(Leistung) AS Anzahl
FROM Leisungstabelle 
GROUP BY Leisung
ORDER BY Anzahl DESC

:?:
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Di 10.06.03 18:58 
Da kommt dann die Fehlermeldung "Column not Found 'Anzahl'".. :(

Au'revoir,
Aya~

PS: Benutz ADT Datenbank

_________________
Aya
I aim for my endless dreams and I know they will come true!
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Di 10.06.03 19:42 
ausblenden Quelltext
1:
2:
3:
4:
SELECT Leisung, COUNT(Leistung) 
FROM Leisungstabelle 
GROUP BY Leisung
ORDER BY Leistung DESC


ausblenden Quelltext
1:
2:
3:
4:
SELECT Leisung, COUNT(Leistung) 
FROM Leisungstabelle 
ORDER BY Leistung DESC
GROUP BY Leisung


Ich weiß jetzt nicht ob ads nen Unterschied macht, aber verscuh mal

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 10.06.03 19:54 
Das würde auch nicht klappen.
Das Query liefert doch eine Tabelle zurück. Die müsste man irgendwo hinschreiben (eine temporäre Tabelle ist gemeint ;-) ) und dort mit COUNT die verschiedenen Einträge suchen. Ob sich das Ganze in einem Query packen lässt, indem man Klammern drum setzt und den einen SELECT dem nächsten übergibt, weiß ich nicht, dafür habe cih zu wenig Erfahrung in SQL.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Di 10.06.03 20:07 
Letzer Versuch: probier mal:

ausblenden Quelltext
1:
2:
3:
4:
5:
SELECT Leisung, COUNT(Leistung) 
FROM Leisungstabelle 
GROUP BY Leistung 
HAVING Leistung
SORT BY Leistung DESC


probieren geht über studieren. Soweit ich das verstanden habe ist Having sowas wie select nur für gruppen...

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Neuromancer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WinNT 4.0 SP6a, WIN 2k Prof SP3, Win XP Prof SP1
D5 Ent, D6 Ent
BeitragVerfasst: Mi 11.06.03 09:08 
ausblenden Quelltext
1:
2:
3:
4:
SELECT Leistung, COUNT(Leistung)
  FROM Leistungstabelle
  GROUP BY Leistung 
  ORDER BY COUNT(Leistung)


funktioniert zumindest auf MS SQL 2000

Gruß
Alfons-G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 307

Win XP Prof, Linux, Win 7
D5 Prof, D7 Architect, D2005 Architect, D2007 Architect
BeitragVerfasst: Mi 11.06.03 10:02 
Bei jeder Datenbank, welche verschachtelte Abfragen zulässt, funktioniert diese Lösung:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
SELECT Leistung, Anzahl
FROM
(Leistung, COUNT(Leistung) AS Anzahl
  FROM Leistungstabelle 
  GROUP BY Leistung)
  ORDER BY Anzahl


8)

_________________
Alfons Grünewald
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Mi 11.06.03 10:04 
hi,

nur als info:

having ist das where der gruppen :)


gr€€tz
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mi 11.06.03 10:17 
Hi Aya,

www.w3schools.com/sql/sql_groupby.asp

die Seite habe ich schon lange bei meinen Favoriten. Die ist echt zu empfehlen.

_________________
Gruß
Hansa
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 11.06.03 10:51 
Neuromancer hat folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
SELECT Leistung, COUNT(Leistung)
  FROM Leistungstabelle
  GROUP BY Leistung 
  ORDER BY COUNT(Leistung)


funktioniert zumindest auf MS SQL 2000

Gruß


Danke :)
Das hat geklappt (ok, falschrum sortiert, aber nen DESC bekomm ich acuh selber hin :P )

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 11.06.03 11:12 
mars hat folgendes geschrieben:
Bin nicht ganz sicher...:
ausblenden Quelltext
1:
2:
3:
4:
SELECT Leistung, COUNT(Leistung) AS Anzahl
FROM Leisungstabelle 
GROUP BY Leisung
ORDER BY Anzahl DESC

:?:


Das hier ist genau das selbe... müsste also auch klappen

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 11.06.03 11:31 
Tweafis hat folgendes geschrieben:
Das hier ist genau das selbe... müsste also auch klappen

Müßte.. geht aber net ;)

_________________
Aya
I aim for my endless dreams and I know they will come true!
ShadowThief
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mi 11.06.03 12:53 
das is zumindest kein sql92 standard,
aber das mit order by count(..) schon.