使用oracle 統計月考勤顯示問題

2025-01-27 23:55:19 字數 3447 閱讀 8807

1樓:文小之

用子查詢+「case when」 or 「decode」~

select (select decode(t.型別,'早班','中班','晚班','null) from table t where

and t.考勤時間=1) 1,select decode(t.型別,'早班','中班','晚班','null) from table t where

and t.考勤時間=2) 2,select decode(t.型別,'早班','中班','晚班','null) from table t where

and t.考勤時間=3) 3,..n

from (select distinct name table) t1;

注:考勤時間需要自己轉換成天數。

t.型別 需要改成table對應的型別欄位。

2樓:網友

二維格式用sql沒法做 sql是用了查詢資料的 顯示格式這個是介面程式設計完成的。

oracle 通過使用者考勤時間顯示本月或者指定月份每日考勤情況

3樓:匿名使用者

這個恐怕要很多的 case when 了。

select

姓名。nvl(

min(case when extract(day from 打卡時間) =1 and to_char(打卡時間, 'am') am' then 備註 else null end,'未打卡') as "1上午",nvl(

max(case when extract(day from 打卡時間) =1 and to_char(打卡時間, 'am') pm' then 備註 else null end,'未打卡') as "1下午",.

nvl(min(

case when extract(day from 打卡時間) =30 and to_char(打卡時間, 'am') am' then 備註 else null end,'未打卡') as "30上午",nvl(

max(case when extract(day from 打卡時間) =30 and to_char(打卡時間, 'am') pm' then 備註 else null end,'未打卡') as "30下午",from表。

whereto_char( 打卡時間, 'yyyymm' )201204'

group by姓名。

excel考勤統計,用什麼函式統計員工乙個月的出勤天數,因為有的員工不是從月頭到月尾的,有從月中開始的

4樓:網友

以你貼圖為例,9月份30天,資料區域應為e4:ah4,那麼實際出勤應為。

counta(e4:ah4)-countif(e4:ah4,"●")-countif(e4:ah4,"╳") 下拉即可。

如果月份31天,那麼資料區域應為e4:ai4注意:公式裡的"●"和"╳"是從插入符號獲得,必須與你**裡的符號一致,你可以將你**裡的符號複製到公式當中,就能避免因符號不一致而公式報錯。

5樓:網友

如果你只是挑大於等於0的個數。

可以用函式count

假設你的月份考勤資料在e3:ai3區域。

在每個員工對應行輸入:=count(e3:ai3)範圍自己更改,我相信應該也沒有加班為負值的人吧。

6樓:網友

可以用if語句判定 =if(單元格名稱》0,"超","負")

oracle統計跨月請假天數

7樓:網友

select to_date('20150312','yyyymmdd') to_date('20150212','yyyymmdd') from dual;

保證兩個是日期型資料就行。

oracle 怎麼實現某月中按每週來分組統計

8樓:胡祖飛為

select to_char(to_date(20160316,'yyyymmdd'),'w') from dual;

to_char函式可以獲取某一天是在該月中的第幾周,然後可以按照這個函式來分組了。

oracle資料庫中怎麼查詢當前年每月的天數,按自然月統計,謝謝!

9樓:網友

樓上的只統計了乙個月的吧。

with t as

select rownum

from dual

connect by rownum <= 12)select to_char (last_day (to_date ( to_char (sysdate, 'yyyy')

lpad (to_char (rownum), 2, 0),'yyyymm')),yyyy-mm'

| '月',to_char (last_day (to_date ( to_char (sysdate, 'yyyy')

lpad (to_char (rownum), 2, 0),'yyyymm')),dd'

| '天'from t

直接全選複製貼上執行。

10樓:匿名使用者

oracle 實現按周,月,季度,年查詢統計資料。

按自然周統計。

select to_char(date,'iw'),sum()

fromwhere

group by to_char(date,'iw')

按自然月統計。

select to_char(date,'mm'),sum()

fromwhere

group by to_char(date,'mm')

按季統計。select to_char(date,'q'),sum()

fromwhere

group by to_char(date,'q')

按年統計。select to_char(date,'yyyy'),sum()

fromwhere

group by to_char(date,'yyyy')

統計的時候注意:以上我寫的統計知識統計當年的,要是跨年在存在邏輯上問題,需要根據需要格式化「統計時間」。可以根據需要參考下面的to_char函式。

附:to_char函式說明。

to_char(x[[,c2],c3])

功能】將*期或資料轉換為char資料型別。

引數】x是乙個date或number資料型別。

c2為格式引數。

c3為nls設定引數。

如果x為*期nlsparm=nls_date_language 控制返回的月份和*份所使用的語言。

如果x為數字nlsparm=nls_numeric_characters 用來指定小數位和千分位的分隔符,以及貨幣符號。

nls_numeric_characters ="dg", nls_currency="string"

在oracle中按要求統計行數怎麼運用sum和count函式

在oracle中,sum一般用於統計某列的和,count用於統計行數。工具 oracle 10g 步驟 1 oracle中emp表有如下資料 2 要求按deptno欄位統計每個deptno下有多少行資料,可用如下語句 select deptno,count from emp group by dep...

oracle怎麼寫儲存過程,oracle 儲存過程,寫一個簡單的Oracle儲存過程

給你示例你參考下 建立儲存過程 create or replace procedure p name 儲存過程名字 i var in int,輸入引數1 o var out varchar2 輸出引數1 is v str varchar2 200 定義儲存過程內部的區域性變數 begin 下面是儲存...

oracle獲取某個月星期日,oracle 獲取某個月第一個星期日

sql select 2 case 3 when to char to date 201207 yyyymm d 1 4 then to date 201207 yyyymm 5 else 6 next day to date 201207 yyyymm 星期日 7 end as 第一個星期日 8 ...