日期:2014-05-17  浏览次数:20858 次

求ACCESS可使用的SQL语句
表1(“/”为了分开数据,防止搞混)

id/name/datetime/sl/bz
1 / a /2012-8-1/ 1/ 1
2 / a /2012-8-1/ 1/ 1
3 / b /2012-7-31/ 1/ 1
4 / b /2012-8-1/ 1/ 0
5 / c /2012-8-1/ 1/ 1




语句要求: 统计8月份bz为1的按sl降序排列

结果:
a / 2
c / 1
d / 0

请写出适合access运行的SQL语句!!

------解决方案--------------------
select * from tb1 where year(datetime) = 2012 and month(datetime) = 8 and bz = 1 order by sl desc
------解决方案--------------------
select name,count(*) from table where year(datetime)='2012' and month(datetime)='8' and bz=1 group by name order by count(*) desc