View Full Version : lệnh count(*) là thế nào nhỉ
bác nào bít ý nghĩa lệnh count(*) la thế nào , trc giờ K chỉ thấy count(tên field) thôi
sontinh2004
18-07-2004, 16:23
Hello Kaz,
Count(*) dem het tat ca cac rows. Count(field) dem cac rows ma co field NOT NULL.
Vi du - Table TruongHoc
TenTruong Phone
Tran Hung Dao 92651145
Le Hong Phong 93546781
Le Quy Do NULL
count(*) returns 3
count(truong) returns 3
count(phone) returns 2
Ban de dang thay duoc su khac biet cua count(*) va count(field)
Here is a demo of 3 different usages of count().
declare @tb table(i int, j int)
insert @tb select 1,1
union all select 2,1
union all select 3,null
select count(*) [count(*)],
count(j) [count(j)],
count(distinct j) [count(distinct(j))]
from @tb
dungtran
02-08-2004, 11:52
cái này người ta thường xài trong trường hợp đã group theo 1 field nào do, vi du group the maphong thi count(*) se ra duoc so nhan vien trong fong do hay dai khai la vay!
Powered by vBulletin® Version 4.2.0 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.