求乙個asp+sql環境顯示sql所有欄位某一時段內容更新情況的統計網頁
1樓:華夏_瀟
connstr="driver=; server=microsof-f59936\sqlexpress;uid=yy;pwd=xx;database=boy"
set conn="")
connstr
timefrom = request("timefrom")timeto = request("timeto")sql = select data, ys, yx, yiu from dbtable where datetime >=timefrom & and datetime <=timeto &
set rs =
do while not
""rs(0) &
rs(1) &
rs(2) &
rs(3) &""
您要的是這種效果嗎?
遇一問題,求高手解答。 sql server單表統計,求歷年、某一時段的資料統
2樓:匿名使用者
假設你需要統計的資料欄位為num,然後需要統計每一年10號到6月18號。
num欄位的總數,那麼sql語句可以這樣寫:
select year(date)m ,sum(num) from table
where right(convert(varchar(8),date,112),4) between '0510' and '0618' -每年的5月10號到6月18號的資料。
group by year(date)--按年份分組。
convert(varchar(8),date,112)是把date欄位的時間(2016-05-15)轉換格式,轉換成如:20160525,然後使用right函式,擷取後面的月份跟日期,擷取4位數為:0515
sql中按不同欄位統計數量的查詢語句,要求在乙個時間段中
3樓:網友
select nvl(t1."date", t2."date") "時間", nvl(, 0) "入院人數", nvl(, 0) "出院人數"
from (select t."入院日期" "date", count(*)cnt1
from "test" t
where t."入院日期" between to_date('20131011') and to_date('20131113')
group by t."入院日期") t1
full join (select t."出院日期" "date", count(*)cnt2
from "test" t
where t."出院日期" between to_date('20131011') and
to_date('20131113')
group by t."出院日期") t2
on t1."date" = t2."date"
order by nvl(t1."date", t2."date")
我這不是中文系統,sql裡的中文是後貼上去的,原來都是英文,保證好用。
4樓:念天地之悠悠
// 查詢7天內每天的金額總數。
dates = ;
for ($i=7; $i >= 0; $i--)
where = " where unix_timestamp(time) >= unix_timestamp('".$dates[0]."')";
order = " group by date_format(time, '%y-%m-%d')";
select = "select date_format(time, '%y-%m-%d') as time,sum(money) as count from czjl";
sql = $select.$where.$order;
orderlist = db::query($sql);
dump($orderlist);
資料庫結果。
你可以參考下。
5樓:網友
select a.日期,isnull(b.入院人數,0) as 入院人數,isnull(c.出院人數,0) as 出院人數。
fromselect 入院日期 as 日期 from table group by 入院日期。
where 入院日期 >= '2013-10-11' and 出院日期 <= '2013-11-13'
unionselect 出院日期 as 日期 from table group by 出院日期。
where 入院日期 >= '2013-10-11' and 出院日期 <= '2013-11-13'
a left join
select count(id) as 入院人數,入院日期 from table group by 入院日期。
b on b.入院日期=a.日期。
left join
select count(id) as 出院人數,出院日期 from table group by 出院日期。
c on c.出院日期 = a.日期。
6樓:常爾
select
case when a.入院日期 is null then b.出院日期 else a.入院日期 end as 時間,case when a.入院人數 is null then 0 else a.入院人數 end as 入院人數,case when b.出院人數 is null then 0 else b.出院人數 end as 出院人數。
fromselect 入院日期,count(1) as 入院人數from tab
group by 入院日期。
a full join
select 出院日期,count(1) as 出院人數from tab
where 出院日期 is not nullgroup by 出院日期。
b on a.入院日期=b.出院日期。
7樓:皮痞
最好的辦法是資料透視表。當然函式countif也可以,只是麻煩一點。
sql讀出記錄並統計出某一欄位的總和
8樓:匿名使用者
select * sum(欄位) from 表名 where 條件 group by 所有欄位。
sql語句:統計指定欄位,等於不同值的條數
9樓:網友
方法一:通過group by ,之後count條數實現。
sql:select count(1) from tablename group by columes;
方法二:通過district函式來直接取出唯一欄位,之後統計數量:
sql:select count(ditrict(columes)) from tablename;
解釋:columes表示的是特殊欄位。
10樓:網友
select count(distinct 欄位1),count(distinct 欄位2),count(distinct 欄位3) from 表名。
乙個計算「每月內每天的某個時段銷量總和」的asp程式,求解答,謝謝。
11樓:酌酒一杯家
<%st=2013-04-01 21:00:00et=2013-04-30 23:
59:59sql="select sum(銷售額) as gs from 表名 where 日期 >=" &st& " and 日期 <=" &et& "
set rs="")
sql,conn,1,1
總銷售額:<%=rs("gs")%>元。
求乙個sql查詢語句,一條記錄,要顯示它在眾多記錄中,按時間排序後的排名
12樓:
那就統計「完成時間」在「張三」的「完成時間」之前的記錄個數:
select count([完成時間])
from [資料表]
where [完成時間]