Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Gruppenfunktion

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich möchte aus einer Tabelle die Anzahl der verschiedenen User ermitteln.

Ich habe folgendes schon gebaut.

SELECT user 
FROM tModerator
GROUP BY user
HAVING count( * ) > 1[/CODE]

Jetzt bekomme ich aber vier Ergebnisse. Ich möchte nur ein Ergebnis. Was muss ich ändern.

Frank

Hallo,

select count(distinct user) from table

Gruß Jaraz

Sollte es aber, hast du auch table durch tModerator ersetzt?

Gruß Jaraz

Also bei mir funktioniert es: Mysql Version 3.23.49-nt


Tabelle: items

+------+---+---+---+---+

| name | a | b | c | d |

+------+---+---+---+---+

| a    | 1 | 2 | 3 | 4 |

| b    | 2 | 3 | 4 | 5 |

| c    | 3 | 4 | 5 | 6 |

| d    | 4 | 5 | 6 | 7 |

| e    | 5 | 6 | 7 | 8 |

| f    | 1 | 7 | 8 | 9 |

+------+---+---+---+---+


mysql> select count(distinct a) from items;

+-------------------+

| count(distinct a) |

+-------------------+

|                 5 |

+-------------------+

1 row in set (0.00 sec)


mysql> select count(distinct  from items;

+-------------------+

| count(distinct  |

+-------------------+

|                 6 |

+-------------------+

1 row in set (0.02 sec)


[/code]

Gruß Jaraz

Also, da es ja anscheinend mit distinct nicht geht hab ich folgenden Vorschlag:

select count(*)

from ( select user

from table

group by user );

Is zwar nicht sonderlich elegant, aber sollte seinen Zweck erfüllen (hoffe ich, hab ich nicht getestet).

Gruß, AxlHammer

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.