CountDistinct (T-SQL)
Möchte man Anzahl von eindeutigen Werten ermitteln, kann man das Argument DISTINCT der Funktion COUNT dazu verwenden.
Hier ist ein Beispiel
use tempdb go create table t1 ( col1 int null ) go insert into t1 values (1),(2),(3),(4),(5), (1),(2),(3),(4), (1),(2),(3), (1),(2), (1), (null) go select count(distinct col1) as CountDistinct, count(all col1) as CountAll, count(*) as CountAsterisk from t1 go drop table t1 go
Hier ist das Resultset
CountDistinct CountAll CountAsterisk ------------- ----------- ------------- 5 15 16
| Print article | This entry was posted by Yury Iwtschenko on 21.06.11 at 21:47:00 . Follow any responses to this post through RSS 2.0. |
Noch kein Feedback
Einen Kommentar hinterlassen
Trackback-Adresse für diesen Eintrag

