SQLサンプル


  TR_出席の表定義




列名 データ型 有効桁数 転送サイズ 小数以下 NULL 許可 既定値
1 KA_年度 VARCHAR 4 4   NO  
2 KA_コード INT 10 4 NO  
3 KA_名称 VARCHAR 100 100   YES  
4 KA_数値1 INT 10 4 YES  
5 KA_数値2 INT 10 4 YES  
6 KA_数値3 INT 10 4 YES  
7 KA_数値4 INT 10 4 YES  
8 KA_担当 VARCHAR 20 20   YES  
9 KA_正式名称 VARCHAR 100 100   YES  
10 KA_区分 VARCHAR 1 1   YES  








  VIEW の作成

  

create view V_週間出欠 as
select
 AB_年度,AB_学生,AB_年月日,AB_時限,AB_FLG,AB_科目
,KA_区分
,datepart(week,convert(datetime,AB_年月日,12)-105) as 週
,
case AB_FLG
when '0' then 'Y'
else NULL
end as 出席
,
case AB_FLG
when '1' then 'Y'
else NULL
end as 欠席
,
case AB_FLG
when '2' then 'Y'
when '3' then 'Y'
else NULL
end as 遅刻早退
,
case AB_FLG
when '4' then 'Y'
else NULL
end as 公欠
,
case AB_FLG
when '5' then 'Y'
else NULL
end as 調整
 from TR_出席,TR_科目
 where
    AB_年度 = KA_年度
and AB_科目 = KA_コード
  

  UNION による集計用データを調整した VIEW の作成

  

create view V_週間出欠2 as
select *
from V_週間出欠 
union all
   select *
   from V_週間出欠
   where
      KA_区分 = '1' 
  

  対象年度用 個人別、週別集計 VIEW の作成

  

create view V_週間出欠3 as
select
 AB_学生
,週
,count(*) as コマ数
,count(出席) as 出席
,count(欠席) as 欠席
,count(遅刻早退) as 遅刻早退
,count(公欠) as 公欠
,count(調整) as 調整
 from V_週間出欠2
 where AB_年度 = '2003'
 group by AB_学生,週
  

  個人累計を 週 = 0 で UNION 追加

  

create view V_週間出欠4 as
select * from V_週間出欠3
union all
select
 AB_学生
,0 as 週
,count(*) as コマ数
,count(出席) as 出席
,count(欠席) as 欠席
,count(遅刻早退) as 遅刻早退
,count(公欠) as 公欠
,count(調整) as 調整
 from V_週間出欠2
 where AB_年度 = '2003'
 and 週 >= 1
 group by AB_学生
  

  該当年度の全ての学生の目的データ

  

select V_週間出欠4.*,氏名,フリガナ
from V_週間出欠4,T_学生
where
   T_学生.年度 = '2003'
and AB_学生 = コード
order by AB_学生,週
  

クラスデータと結合した上記 SELECT 構文により、クラス別集計表の出力用の中間テーブルを作成する




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[msde]
claudebot
24/04/19 04:15:07
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube