Autor Beitrag
webbi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 142

Win XP Pro SP2, Debian GNU/Linux 2.6
D5 Pro, D7 Pro, BDS2006, Kylix3, MS-VS 2005
BeitragVerfasst: Mo 04.07.05 13:54 
Hallo!


Ich habe eine Adress-Tabelle und möchte wissen, welche PLZ wie oft vorkommt - und das mit einem Query...

Also bei Select Distinct Plz from namen noch zu jeder Zeile der Ausgabe die Anzahl daneben...

Geht das?
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 04.07.05 15:06 
Hallo,

folgendermassen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  SQL.Text:=
    'SELECT DISTINCT plz, COUNT(plz)'+#13#10+
    'FROM namen'+#13#10+
    'GROUP BY plz'+#13#10+
    'ORDER BY plz';

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

Win XP Pro SP2, Debian GNU/Linux 2.6
D5 Pro, D7 Pro, BDS2006, Kylix3, MS-VS 2005
BeitragVerfasst: Di 05.07.05 06:43 
funzt. Danke!
jaevencooler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 166
Erhaltene Danke: 6

MS-DOS,Win32, Win95, Win 98, Me,XP, Linux, NT4.0, NT 2000-2008, Vista, Windows 7
Turbo Pascal,D1 Enter,D2 Enter,D3 Enter,D5 Enter, Kylix, D2007, PL/SQL, MS/SQL, Delphi 2010, Delphi XE
BeitragVerfasst: Di 05.07.05 07:57 
Moin, Moin,

also so geht es natürlich aber besser und schneller wäre:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
select count(plz) from namen
group by plz
order by plz  // Viele Datenbanken implizieren ein Order by 
              // wenn ein group by benutzt wird !! 
              // und ist daher nicht immer nötig  :lol:


user profile iconsmiegel hat folgendes geschrieben:
Hallo,

folgendermassen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  SQL.Text:=
    'SELECT DISTINCT plz, COUNT(plz)'+#13#10+
    'FROM namen'+#13#10+
    'GROUP BY plz'+#13#10+
    'ORDER BY plz';



Beste Grüße
Michael[list=]

_________________
Wissen ist Macht, nichts wissen macht auch nichts...
webbi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 142

Win XP Pro SP2, Debian GNU/Linux 2.6
D5 Pro, D7 Pro, BDS2006, Kylix3, MS-VS 2005
BeitragVerfasst: Di 12.07.05 08:43 
Auf diese Art bekomm ich aber nur die Spalte in der der Count aber nicht die dazugehörige PLZ steht...
stifflersmom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Di 12.07.05 09:58 
Na dann setzt Du VOR das count(plz) eben noch ein plz,

Moin
webbi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 142

Win XP Pro SP2, Debian GNU/Linux 2.6
D5 Pro, D7 Pro, BDS2006, Kylix3, MS-VS 2005
BeitragVerfasst: Di 12.07.05 13:57 
eben, dann haben wir den gleichen Query wie ihn schon smiegel gepostet hat...

das meinte ich...