A. sql server中查詢每個班級的出勤率(出勤人數/班級人數),有學員信息表和出勤表(到校和沒到校的都有記錄)怎麼
每個子查詢,查詢出來的結果都有可能是多個,因為你分組了。他會把每個班級的人數進行統計,結果就是多個
這樣就可以了:
select rount(t1.實際出勤人數/t2.班級人數,2) from
(select count(goschool) 實際出勤人數 ,cclass from tx_scheck where goschool='到校' group by cclass) t1
inner join
(select count(*) 班級人數 , sclass from tx_xsxxb a where a.ifgoschool='在校' group by sclass) t2 on t1.cclass = t2.sclass
B. SQL : 表A (id 出勤時間)查詢出某個ID在某個時間內的出勤記錄 怎麼寫語句
哥們,你給的A表沒有有關員工標識的列,就是指出哪條是趙四的,哪條是張三的,別人怎麼幫你
假設表A是這樣的 :表A ID 出勤時間(datatime(8)) 用戶名稱(或用戶ID)
那麼SQL是:
SELECT COUNT(id) ,用戶名稱(或用戶ID)
FROM A
GROUP BY 用戶名稱(或用戶ID)
把表數據按用戶分組,然後取出每個組的出出勤次數COUNT(id),和對應的用戶
C. sql中怎麼統計工作日出勤情況
1.你還得有張日期表,規定一年365天哪天是周末,哪天是節假日,也就是日期類型(其實就是日歷)
2.出勤表中日期和日期表中的日期連接根據日期類型就知道哪天是節假日哪天是正常上班時間了
3.曠工天數應該就是出勤表中上班簽到時間或者下班簽到時間為空的話就算曠工了
4.休息日加班天數就是出勤表和日期表連接,日期類型是休息日,並且上班簽到和下班簽到時間都不為空了
總之,有張日期表什麼都能檢索出來了
D. 求SQL查詢語句。。有出勤表。1個人有多次出勤。。求出勤次數最多的人的名字
select c.user_name
from (select count(*) as cout, t.user_name
from tbl_cq t
group by t.user_name) c
where c.cout = (select max(cout)
from (select count(*) as cout, t.user_name
from tbl_cq t
group by t.user_name));
或者可以用視圖或臨時表來簡化該查詢語句
E. sql 考勤統計查詢
select name,dept,count(*) 工作天數,sum(xbsj-sbsj) 工作累計時間,count(case when kqqk=1 then 1 end) 遲到天數,count(case when kqqk=2 then 1 end) 早退天數
from table1 join table2 on table1.uid=table2.uid
group by name,dept
F. 員工考勤統計怎麼寫sql語句,查詢出勤率,遲到次數,早退次數,曠工次數
你的給子段,給點模擬數據
G. 請教一條關於SQL查詢考勤數據的語句
記錄吐吐舌頭疼了。
H. sql查詢連續出勤記錄
樓主的筆誤很多啊,看看是不是這個效果。
declare @tab table (dt datetime , ur varchar(12))
insert into @tab
select '2007-01-02','2014' union all
select '2007-01-04','2014' union all
select '2007-01-08','2014' union all
select '2007-01-09','2014' union all
select '2007-01-10','2014' union all
select '2007-01-11','2014' union all
select '2007-01-13','2014' union all
select '2007-01-14','2014' union all
select '2007-01-15','2014' union all
select '2007-01-17','2014' union all
select '2007-01-18','2014' union all
select '2007-01-20','2014' union all
select '2007-01-21','2014' union all
select '2007-01-22','2014' union all
select '2007-01-23','2014' union all
select '2007-01-25','2014' union all
select '2007-01-29','2014'
select *
from @tab a
where exists(select * from @tab where datediff(dd,dt,a.dt) in (1,-1))
order by 1
I. 求助高手啊,出勤率sql語句怎麼寫
你表結構是什麼樣的啊,現在只能給你個思路了,比如這個月全勤是26天,超過或等於26天的就100%,沒超過的,就出勤天數/26就OK了
J. sql 統計出勤狀況 select
select a.name,
(select count(1) from b
where b.usid=a.usid and b.狀態='遲到' group by b.usid) as 『遲到』,
(select count(1) from b
where b.usid=a.usid and b.狀態='早退' group by b.usid) as 『早退』
from a