Instances of grouped statistics in Access
Finishing from: http://expert.111cn.net/Expert/topic/2727/2727523.xml?temp=.1140711
There are fields under the online table:
Description: User name version is registered
Field: Usr_name ver isreg
The following records are present in the table:
AAA CN True
BBB cn false
CCC en true
DDD FR True
Result requirements: Query the number of registered users and unregistered users for each version, resulting in the following structure:
Version Registration quantity not registered
CN 1 1
En 1 0
Fr 1 0
Ask how SQL statements are written in Access 2000 environment
Troubled days finally resolved:
1. One of the ways in MS SQL SERVER 2000:
Select Ver as version, sum (case when Isreg=true then 1 else 0) as registered number, sum (case when Isreg=false then 1 else 0 end) as not registered Quantity from online group by version
2. Access 2000 the test passes:
Select DISTINCT ver as version, (select COUNT (*) from online WHERE ver=m.ver and isreg=true) as registered quantity, (select count (*) from onl Ine WHERE Ver=m.ver and Isreg=false) as unregistered quantity
From online as M
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.