SELECT COUNT(username) FROM PatientTable WHERE StartTime>=CONVERT(Datetime,'2006-01-01') AND StartTime<=CONVERT(Datetime,'2006-02-01')
select count(id) from table where 疾病名称='水痘' and 发病数量 between '2006-01-01' and '2006-02-01'
select count(id) from table where 疾病名称='水痘' and 发病时间 between '2006-01-01' and '2006-02-01'
select 发病时间, count(*) from table where 疾病名称='水痘' and 发病时间 between '2006-01-01' and '2006-02-01' group by 发病时间
select count(id) from table where 疾病名称='水痘' and 发病数量 between '2006-01-01' and '2006-02-01'
select DatePart( month,发病时间)+ '月' + DatePart( day, 发病时间) + '日' AS 发病日期, count(*)AS Num from table where 疾病名称='水痘' and 发病时间 between '2006-01-01' and '2006-02-01' group by DatePart( month,发病时间), DatePart( day, 发病时间)
select count(id) from table where 疾病名称='水痘' and 发病数量 between '2006-01-01' and '2006-02-01'
select count(id) from table where 疾病名称='水痘' and 发病数量 between '2006-01-01' and '2006-02-01'
返回的DataTable应该有两列。一列是时间,一列是发病数量。
select trunc(发病日期) AS 时间,count(*) AS 数量 FROM disease.INFECTIOUS where 发病日期 between to_date('2006-01-01','yyyy-mm-dd') and to_date('2007-02-01','yyyy-mm-dd') and 疾病编号='水痘' group by trunc(发病日期),疾病编号 ORDER BY 时间 ASC 这样写对于单个是对的。 1 4 2 2007-1-26 5 3 2007-1-27 8 4 2007-1-28 7 5 2007-1-29 3 6 2007-1-30 9 7 2007-1-31 6 8 2007-2-1 8 但如果是所有的疾病的话。语句如下 select trunc(发病日期) AS 时间,count(*) AS 数量 FROM disease.INFECTIOUS where 发病日期 between to_date('2006-01-01','yyyy-mm-dd') and to_date('2007-02-01','yyyy-mm-dd') group by trunc(发病日期),疾病编号 ORDER BY 时间 ASC 这样写对于单个是对的。但结果好像不对 1 2007-1-25 1 2 2007-1-25 1 3 2007-1-25 4 4 2007-1-25 1 5 2007-1-25 2 6 2007-1-25 3 7 2007-1-26 5 8 2007-1-26 1 9 2007-1-26 2 10 2007-1-26 1 11 2007-1-26 1 12 2007-1-26 3 13 2007-1-26 1 14 2007-1-26 1 15 2007-1-26 1 16 2007-1-26 3 17 2007-1-26 1 18 2007-1-26 1 19 2007-1-26 1 20 2007-1-26 1 21 2007-1-27 2 这个是怎么回事呢?
废话,下面这个是所有疾病的,上面那个只是水痘的 要所有疾病分组效果应该这样select trunc(发病日期) AS 时间,count(*) AS 数量 FROM disease.INFECTIOUS where 发病日期 between to_date('2006-01-01','yyyy-mm-dd') and to_date('2007-02-01','yyyy-mm-dd') group by trunc(发病日期) ORDER BY 时间 ASC
and 发病时间 between '2006-01-01' and '2006-02-01' group by DatePart( month,发病时间), DatePart( day, 发病时间)
FROM disease.INFECTIOUS
where 发病日期 between to_date('2006-01-01','yyyy-mm-dd')
and to_date('2007-02-01','yyyy-mm-dd')
and 疾病编号='水痘'
group by trunc(发病日期),疾病编号 ORDER BY 时间 ASC 这样写对于单个是对的。
1 4
2 2007-1-26 5
3 2007-1-27 8
4 2007-1-28 7
5 2007-1-29 3
6 2007-1-30 9
7 2007-1-31 6
8 2007-2-1 8
但如果是所有的疾病的话。语句如下
select trunc(发病日期) AS 时间,count(*) AS 数量
FROM disease.INFECTIOUS
where 发病日期 between to_date('2006-01-01','yyyy-mm-dd')
and to_date('2007-02-01','yyyy-mm-dd')
group by trunc(发病日期),疾病编号 ORDER BY 时间 ASC 这样写对于单个是对的。但结果好像不对
1 2007-1-25 1
2 2007-1-25 1
3 2007-1-25 4
4 2007-1-25 1
5 2007-1-25 2
6 2007-1-25 3
7 2007-1-26 5
8 2007-1-26 1
9 2007-1-26 2
10 2007-1-26 1
11 2007-1-26 1
12 2007-1-26 3
13 2007-1-26 1
14 2007-1-26 1
15 2007-1-26 1
16 2007-1-26 3
17 2007-1-26 1
18 2007-1-26 1
19 2007-1-26 1
20 2007-1-26 1
21 2007-1-27 2
这个是怎么回事呢?
要所有疾病分组效果应该这样select trunc(发病日期) AS 时间,count(*) AS 数量
FROM disease.INFECTIOUS
where 发病日期 between to_date('2006-01-01','yyyy-mm-dd')
and to_date('2007-02-01','yyyy-mm-dd')
group by trunc(发病日期) ORDER BY 时间 ASC