2011年12月16日金曜日

サーバへの接続方法

1.ファイルのアップロード/ダウンロード

Windowsで使用できるGUIのSFTPツールであるFilezillaをインストール
Download



2.DBへの接続(MySQL Workbench)

Windowsで使用できるGUIのMySQLフロントエンドツールであるMySQL Workbenchをインストール
Download

Server Administration -> New Server Instanceから接続設定作成






2011年12月15日木曜日

PHP-MySQL連携

1.php-mysqlモジュールをインストール
$ su
# yum install php-mysql
# service httpd stop
# service httpd start
# service mysqld stop
# service mysqld start 

2.以下のファイルを作成し,/var/www/html以下に配置
 index.php
<HTML>
<HEAD> 
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>SA2011 sample</TITLE>
<STYLE TYPE="text/css"> 
<!-- 
 .table1 {
  width: 600px;
  border-collapse: collapse;
  border: 1px #111111 solid;
 }
 .table1 TD { 
  border: 1px #111111 solid;
 } 
-->
</STYLE>
</HEAD>
<BODY>

<H1>SA2011 SAMPLE PAGE</H1>

<br />

<a href='status.php?name="sato"&pass="******"'>XML SAMPLE</a>

<?php
 $db_user  = "root";
 $db_password = "******";
 $db_name = "sample";
 $db_table_name = "users";
 $db_host  = "localhost";

 $db = mysql_connect($db_host,$db_user,$db_password);
 mysql_select_db($db_name,$db);


 $strsql = "SET CHARACTER SET UTF8";
 mysql_query($strsql,$db);


 $str_sql = "select * from ".$db_table_name;
 $rs = mysql_query($str_sql,$db);
 $num = mysql_num_fields($rs);

 print("<table CLASS='table1'><tr><th colspan=7>Registered User List</th></tr>");
 print("<tr>");
 for ($i=0;$i<$num;$i++){
  print("<td><b>".mysql_field_name($rs,$i)."</b></td>");
 }
 print("</tr>");
 while($row=mysql_fetch_array($rs)){
  print("<tr>");
  for($j=0;$j<$num;$j++){
   print("<td>".$row[$j]."</td>");
  }
  print("</tr>");
 }

 print("</table>");

 mysql_free_result($rs);
 mysql_close($db);
?>

</BODY>
</HTML>

status.php
<?php
 $db_user  = "root";
 $db_password = "******";
 $db_name = "sample";
 $db_table_name = "users";
 $db_host  = "localhost";

 //create xml
 header('Content-type: text/xml; charset=utf-8');
 echo '<?xml version="1.0"?><sample>';

 $user_name = null;
 $user_pass = null;

 if(isset($_GET['name'])) {
  $user_name = $_GET['name'];
  $user_pass = $_GET['pass'];

  $con = mysql_connect($db_host,$db_user,$db_password) or die("error!");
  mysql_select_db($db_name,$con) or die("DB is not exist");
  $strsql = "SET CHARACTER SET UTF8";
  mysql_query($strsql,$con);
  $strsql = "SELECT money, item, kana, studentId FROM ".$db_table_name." WHERE name = $user_name AND pass = $user_pass;";
  $res = mysql_query($strsql,$con);

  while ($item = mysql_fetch_array($res)) {
   print "<user_status><money>".$item[0]."</money><item>".$item[1]."</item><kana>".$item[2]."</kana><studentId>".$item[3]."</studentId></user_status>";
  }

  mysql_close($con);
 }

 echo '</sample>'; 
?>

2011年12月9日金曜日

各チーム毎のFLASH設置サーバIPアドレス割り当て

FLASH設置サーバIPアドレス
IPアドレス利用者名
10.2.5.3佐藤
10.2.5.131team神崎
10.2.5.132team秋山
10.2.5.133teamふなや
10.2.5.134team中山
10.2.5.135solo間宮
10.2.5.136予備

※WEBサーバ,DBサーバ設定済みです.
※DBには初期データ投入済みです.http://10.2.5.***にアクセスして,内容を確認してください.
※ファイルの設置には,SFTPツール(Filezilla等)を利用します.
※DBへの値投入/変更には,MySQL Workbenchを利用します.

2011年12月8日木曜日

DBサーバ構築


1.MySQLサーバのインストール

#yum install mysql-server



2.MySQLサーバを,サーバ起動時に自動的に起動するように設定

#chkconfig mysqld on


3.MySQLサーバの起動
(自動起動設定が反映された次回起動以降であれば,このようなコマンドは不要ですが,今回は自動起動はなされていないため,手動にてMySQLサーバを起動)

#service mysqld start



4.MySQLサーバの初期設定
セキュリティーを確保するために,何カ所かの設定変更が必要です.
従来は個別に設定を施していましたが,それらを纏めて設定する便利な対話式のツールがあるので,今回はそちらを利用します.
(もちろん個別に設定を行ってもかまいません)

#mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! &nbsp;PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current password for the root user. &nbsp;If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. 
Enter current password for root (enter for none):

*1 初期状態ではrootにパスワードは設定されていない為,何も入力せずenter

OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.
Set root password? [Y/n] Y

*2 rootのパスワードを設定するために,Yを入力後enter

New password:********

*3 設定したいパスワードを入力後enter

Re-enter new password:********

*4 再度設定したいパスワードを入力しenter

Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. &nbsp;This is intended only for testing, and to make the installation go a bit smoother. &nbsp;You should remove them before moving into a production environment. 
Remove anonymous users? [Y/n] Y

*5 初期状態で登録されている匿名ユーザーを削除する為にYを入力しenter

... Success!
Normally, root should only be allowed to connect from 'localhost'. &nbsp;This ensures that someone cannot guess at the root password from the network. 
Disallow root login remotely? [Y/n] n

*6 初期状態で設定されている外部からのrootアカウントでのログイン設定.今回はrootでのログインを許可する方針の為nを選択しenter

... skipping.
By default, MySQL comes with a database named 'test' that anyone can access. &nbsp;This is also intended only for testing, and should be removed before moving into a production environment. 
Remove test database and access to it? [Y/n] Y

*7 初期状態で用意されているtestテーブルを削除する為にYを入力しenter

- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 
Reload privilege tables now? [Y/n] Y

*8 設定ファイルを再読込するために,Yを入力しenter

... Success!
Cleaning up...
All done! &nbsp;If you've completed all of the above steps, your MySQL installation should now be secure.
Thanks for using MySQL!

5.コマンドラインからMySQLサーバに接続

#mysql -u root -p


6.MySQL Workbenchから接続

Windowsで使用できるGUIツールであるMySQL Workbenchをインストール
Download

Server Administration -> New Server Instanceから接続設定作成






2011年12月1日木曜日

初期設定~WEBサーバ構築


1.OS及びKernelのVersion確認
#cat /etc/issue
#uname -a

2.メモリ使用量の確認
#free -m

3.ディスク使用量の確認
#df -H

4.稼働しているプロセスの確認
#ps aux

5.インストールされているアプリケーションの確認
#rpm -aq

6.installされているアプリケーションの数を表示
#rpm -aq | wc -l

7.自動起動設定されているアプリケーションの確認
#chkconfig

8.不要なサービスの自動起動設定解除
#chkconfig (サービス名) off

例)chkconfig ip6tables off

9.yum準備
#yum install yum-fastestmirror
#yum install yum-utils

10.NTPインストール
#yum install ntp
#chkconfig ntpd on
#chkconfig | grep ntp
#service ntpd start

11.PHPインストール
#yum install php
#vi /etc/php.ini
memory_limit = 16M ; Maximum amount of memory a script may consume

12.Webサーバ(httpd)インストール
#yum install httpd
#chkconfig httpd on
#service httpd start

13.Firewall設定
iptablesのルール初期化
# /sbin/iptables -F

現在のルール確認
#iptables -L

fire wallにルール追加
#vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80    -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306  -j ACCEPT

service iptables restart

13.動作確認
ブラウザから以下のアドレスにアクセスし,テスト画面が表示されることを確認
http://10.2.5.***

2011年11月24日木曜日

仮想環境構築手順(クライアント編)

1.データストアブラウザで仮想環境をコピーすると,コピー時にMACアドレスが自動的に変更され,結果的にOSが別NICが追加され,既存NICが削除されたと判断するようです.
そこで起動時にNICの確認を行っているスクリプト中の老番のethを有効にするため,若番のethはコメントアウトする.
/etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1022:0x2000 (pcnet32) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1f:ce:60", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:00:00:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x1022:0x2000 (pcnet32) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1f:ce:60", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:00:00:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

2.クライアントのIPアドレスをstaticに変更する

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.2.5.***
NETMASK=255.0.0.0
GATEWAY=10.1.0.1

IPアドレス割り当て
IPアドレス利用者名
10.2.5.2佐藤
10.2.5.101相木
10.2.5.102井上
10.2.5.103小川
10.2.5.104川村
10.2.5.105小暮
10.2.5.106関野
10.2.5.107高橋
10.2.5.108武山
10.2.5.109橋本
10.2.5.110浅野
10.2.5.111平嶋
10.2.5.112佐々木
10.2.5.113塩津
10.2.5.114熊谷
10.2.5.115内谷
10.2.5.116大嶋
10.2.5.117澁谷
10.2.5.118
10.2.5.119長島
10.2.5.120溝部
10.2.5.121山口
10.2.5.122山崎
10.2.5.123吉田
10.2.5.124予備1
10.2.5.125予備2
10.2.5.100共有サーバ(物理サーバ)



※初期状態でSSH可能です.
※httpd,mysql-server,PHPは別途インストールする必要があります.

仮想環境構築手順(サーバ編)

使用環境:VMware ESXi 4.1.0
IP Address10.2.5.1
Subnet Mask255.0.0.0
Default Gateway10.1.0.1

仮想化計画:
使用サーバがメモリ16GB/HDD(SSD)80GBであることから,1インスタンスあたり,
HDD使用量=2.8GB
メモリ使用量=512MB(*1)
を目安とする.
これにより最大26インスタンス同時動作可能と思われる.

(*1)ESXiではクライアント間で動的にメモリを配分可能なため,サーバの物理搭載メモリ量を考慮して各インスタンスのメモリ量を決める必要はないが,今回はわかりやすさを優先して512MBとしている.動作が安定したら1GBに増量してもよいかも?


各インスタンス設定:
CentOS 6.0(最少インストール)

最小インストール時のメモリ,及びディスク使用量:

# df -H
FilesystemSizeUsedAvailUse%Mounted on
/dev/mapper/VolGroup-lv_root1.7G625M920M41%/
tmpfs262M0262M0%/dev/shm
/dev/sda1508M46M437M10%/boot
※1GB弱利用可能

# free -m

totalusedfreesharedbufferscached
Mem:499814180530
Swap:7870787


※418MB利用可能

vSphere Client設定

















※ESXi4.0以前でSSHを有効にする際は,以下の通り.
1.ESXiのコンソール画面で[Alt]+[F1](コーンソール画面の色が変化)
2."unsupported"と入力
3.メンテナンス用のコンソール画面で,パスワードを入力
4.シェルのプロンプトが表示
5.ホスト再起動
6.外部から接続の確認

※ESXi4.1以降でSSHを有効にする際は,以下の通り.
1.ESXiのコンソール画面から[F2]
2.Troubleshooting Options
3.Enable Remoto Tech Support(SSH)

共有サーバ設定変更


IPアドレス
10.5.1.240 ---> 10.2.5.100

WEBサーバ設定不調時は以下のコマンド
/etc/init.d/httpd restart

2011年11月21日月曜日

オリジナル・データベースの作成手順

1.最終的な画面をイメージ
作成したデータベースを使用する際のフォームまたはレポートを想像し、スケッチしておく。
DB完成イメージ
2.要素の抽出・分類
1で作成したスケッチに含まれる文字列(要素)を抜き出し、内容毎に分類する。
要素抽出/分類

3.テーブルの作成
2で作成した分類毎の要素を使ってテーブルを作成し、リレーションを付加する。
T学生マスター(データシートビュー)
T学生マスター(デザインビュー)

T出席状況(データシートビュー)
T出席状況(デザインビュー)
リレーションシップ

4.クエリの作成
3で作成したテーブルを基として、1で使用する値を抽出するクエリを作成する。
Q出席状況(データシートビュー)
Q出席状況(デザインビュー)

5.フォームの作成
4で作成したクエリを基として、1で使用する値を表示するフォームを作成する。
F出席状況(フォームビュー)

F出席状況(デザインビュー)

必要出席コマ数
=Int(Count([出席日])*6*0.8)

出席状況
=Abs(Sum([1限目]+[2限目]+[3限目]+[4限目]+[5限目]+[6限目]))

6.完成
残り日数により日数の背景色が変化する様に変更
右クリック→条件付き書式

条件付き書式の設定

F出席状況2(フォームビュー)

F出席状況2(デザインビュー)

※サンプルファイルをダウンロード

2011年11月17日木曜日

外部APIを利用したWEBサービスのサンプル(9)

気象情報(天気予報)APIの利用

表示例

LINK

API URL
http://www.google.com/ig/api?weather=Yokohama,Kanagawa

取得されるXMLのサンプル
<xml_api_reply version="1">
 <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
  <forecast_information>
   <city data="Yokohama, Kanagawa Prefecture"/>
   <postal_code data="Yokohama,Kanagawa"/>
   <latitude_e6 data=""/>
   <longitude_e6 data=""/>
   <forecast_date data="2011-11-17"/>
   <current_date_time data="1970-01-01 00:00:00 +0000"/>
   <unit_system data="SI"/>
  </forecast_information>
  <current_conditions>
   <condition data="ところにより曇り"/>
   <temp_f data="63"/>
   <temp_c data="17"/>
   <humidity data="湿度 : 39%"/>
   <icon data="/ig/images/weather/jp_cloudy.gif"/>
   <wind_condition data="風: 南東 4 m/s"/>
  </current_conditions>
  <forecast_conditions>
   <day_of_week data="木"/>
   <low data="11"/>
   <high data="18"/>
   <icon data="/ig/images/weather/jp_sunny.gif"/>
   <condition data="ところにより晴れ"/>
  </forecast_conditions>
  <forecast_conditions>
   <day_of_week data="金"/>
   <low data="10"/>
   <high data="18"/>
   <icon data="/ig/images/weather/jp_cloudy.gif"/>
   <condition data="曇り"/>
   </forecast_conditions>
  <forecast_conditions>
   <day_of_week data="土"/>
   <low data="16"/>
   <high data="21"/>
   <icon data="/ig/images/weather/jp_rainysometimescloudy.gif"/>
   <condition data="雨の可能性"/>
  </forecast_conditions>
  <forecast_conditions>
   <day_of_week data="日"/>
   <low data="14"/>
   <high data="22"/>
   <icon data="/ig/images/weather/jp_rainysometimescloudy.gif"/>
   <condition data="雨の可能性"/>
  </forecast_conditions>
 </weather>
</xml_api_reply>

weather.php
<?php
 $area = "Yokohama";
 $url = "http://www.google.com/ig/api?weather=".$area;

 $xml = simplexml_load_file($url);

//forecast_information
 $city = $xml->weather->forecast_information->city->attributes();
 $forecast_date = $xml->weather->forecast_information->forecast_date->attributes();
 $unit_system = $xml->weather->forecast_information->unit_system->attributes();

//current_conditions
 $current_condition = $xml->weather->current_conditions->condition->attributes();
 $temp_c = $xml->weather->current_conditions->temp_c->attributes();
 $humidity = $xml->weather->current_conditions->humidity->attributes();
 $current_icon = $xml->weather->current_conditions->icon->attributes();
 $wind_condition = $xml->weather->current_conditions->wind_condition->attributes();

//forecast_conditions
 $day_of_week = $xml->weather->forecast_conditions->day_of_week->attributes();
 $low = $xml->weather->forecast_conditions->low->attributes();
 $high = $xml->weather->forecast_conditions->high->attributes();
 $forecast_icon = $xml->weather->forecast_conditions->icon->attributes();
 $forecast_condition = $xml->weather->forecast_conditions->conditionh->attributes();

print<<<EOF
 <html>
 <head>
 <title>google weather sample</title>
 </head>
 <body>
EOF;

 print "場所:".$city."<br />";
 print "予報日:".$forecast_date."<br />";
 print "単位:".$unit_system."<br />";
 print "<br />";
 print "現在の状況<br />";
 print "状況:".$current_condition."<br />";
 print "気温:".$temp_c."<br />";
 print "湿度:".$humidity."<br />";
 print "<img src='http://www.google.com".$current_icon."'><br />";
 print "風向:".$wind_condition."<br />";
 print "<br />";
 print "明日の天気<br />";
 print "曜日:".$day_of_week."<br />";
 print "最低気温:".$low."<br />";
 print "最高気温:".$high."<br />";
 print "<img src='http://www.google.com".$forecast_icon."'><br />";
 print "状況:".$forecast_condition."<br />";

print<<<EOF
 </body>
 </html>
EOF;
?>

外部APIを利用したWEBサービスのサンプル(8)

twitter public timeline検索APIの利用
表示例

LINK

取得されるXMLのサンプル(一部抜粋)
<?xml version="1.0" encoding="utf-8"?>
<rss>
 <channel>
   <item>
    <title>@Copa3 ありがとうございます。横浜ですかそりゃ、とおくていけませんわ。</title>
    <link>http://twitter.com/sendaimo/statuses/137026307379822592</link>
    <description>@&lt;a class=" " href="http://twitter.com/Copa3"&gt;Copa3&lt;/a&gt; ありがとうございます。&lt;em&gt;横浜&lt;/em&gt;ですかそりゃ、とおくていけませんわ。</description>
    <pubDate>Thu, 17 Nov 2011 04:36:32 +0000</pubDate>
    <guid>http://twitter.com/sendaimo/statuses/137026307379822592</guid>
    <author>sendaimo@twitter.com (Kimiaki Nagase)</author>
    <media:content type="image/jpg" height="48" width="48" url="http://a0.twimg.com/profile_images/825361762/saxbobo02_normal.gif" xmlns:media="http://search.yahoo.com/mrss/" />
    <google:image_link xmlns:google="http://base.google.com/ns/1.0">http://a0.twimg.com/profile_images/825361762/saxbobo02_normal.gif</google:image_link>
    <twitter:metadata xmlns:twitter="http://api.twitter.com/">
     <twitter:result_type>recent</twitter:result_type>
    </twitter:metadata>
   </item>
 </channel>
</rss>

twitter_timeline.php
<?php
 $word = "横浜";
 $url = "http://search.twitter.com/search.rss?q=".$word;

 $rss = simplexml_load_file($url);

 $title = $rss->channel->item->title;
 $link = $rss->channel->item->link;
 $description = $rss->channel->item->description;
 $pubDate = $rss->channel->item->pubDate;
 $author = $rss->channel->item->author;

print<<<EOF
 <html>
 <head>
 <title>twitter sample</title>
 </head>
 <body>
EOF;

 print "title : ".$title."<br />";
 print "link : ".$link."<br />";
 print "description : ".$description."<br />";
 print "pubDate : ".$pubDate."<br />";
 print "author : ".$author."<br />";
 print "image_link : ".$iage_link."<br />";

print<<<EOF
 </body>
 </html>
EOF;
?>

2011年11月14日月曜日

第5章練習問題

Access2003応用
練習問題(P112)

「Q時間単価更新クエリ」内の登録期間を表示する部分は

登録期間:DateDiff("m", [登録日], Date())
ではなく
登録期間:DateDiff("m", [登録日], "2004/11/14")
を使用すること.


第5章で作成した,勤続期間により時間単価が変更されたデータを用いて,第4章と同様の追加課題を行う.
(第4章とは対象とするデータが異なる事に注意)

今回作成するクエリの中に,勤続期間によって時間単価が変化するフィールドを追加する場合,以下の式が利用できる.
時間単価2: IIf(DateDiff("m",[登録日],"2004/11/14")>=36,[時間単価]+30,[時間単価])
以後賃金を計算する箇所で,フィールド名「時間単価」の部分を「時間単価2」に変更すれば,勤続期間を考慮した時間単価を使用した賃金の計算が可能になる.
追加課題1:
勤務時間が6時間をこえる場合は,1時間の休憩を入れなければならないとする.
このような場合の賃金を表示するフィールドを,「賃金2」というフィールド名で作成せよ.

追加課題2:
退勤時刻が18:00を過ぎた場合,18:00以降の賃金が1.25倍になるとする.
このような場合の賃金を表示するフィールドを,「賃金3」というフィールド名で作成せよ.

追加課題3:
追加課題1と追加課題2の内容を同時に満たすフィールドを,「賃金4」というフィールド名で作成せよ.

2011年11月9日水曜日

第4章練習問題

Access2003応用
練習問題(P73)

追加課題1:
勤務時間が6時間をこえる場合は,1時間の休憩を入れなければならないとする.
このような場合の賃金を表示するフィールドを,「賃金2」というフィールド名で作成せよ.
賃金2: IIf(
    [勤務時間]>6,
    [時間単価]*([勤務時間]-1),
    [時間単価]*[勤務時間]
)

追加課題2:
退勤時刻が18:00を過ぎた場合,18:00以降の賃金が1.25倍になるとする.
このような場合の賃金を表示するフィールドを,「賃金3」というフィールド名で作成せよ.
追加課題2場合分け: IIf(
    DateDiff("n", [退勤時刻], "18:00")>=0,
    "1",
    IIf(
        DateDiff("n", [出勤時刻], "18:00")>=0,
        "2",
        "3"
    )
)
賃金3: IIf(
    DateDiff("n", [退勤時刻], "18:00")>=0,
    [時間単価]*[勤務時間],
    IIf(
        DateDiff("n", [出勤時刻], "18:00")>0,
        DateDiff("n", [出勤時刻], "18:00")/60*[時間単価]+DateDiff("n", "18:00", [退勤時刻])/60*[時間単価]*1.25,
        [時間単価]*[勤務時間]*1.25
    )
)

追加課題3:
追加課題1と追加課題2の内容を同時に満たすフィールドを,「賃金4」というフィールド名で作成せよ.
追加課題3場合分け: IIf(
    DateDiff("n", [退勤時刻], "18:00")>=0,
    IIf(
        [勤務時間]>6,
        "1-1",
        "1-2"
    ),
    IIf(
        DateDiff("n", [出勤時刻], "18:00")>=0,
        IIf(
            [勤務時間]>6,
            "2-1",
            "2-2"
        ),
        IIf(
            [勤務時間]>6,
            "3-1",
            "3-2"
        )
    )
)
賃金4: IIf(
    DateDiff("n", [退勤時刻], "18:00")>=0,
    IIf(
        [勤務時間]>6,
        [時間単価]*([勤務時間]-1),
        [時間単価]*[勤務時間]
    ),
    IIf(
        DateDiff("n", [出勤時刻], "18:00")>0,
        IIf(
            [勤務時間]>6,
            (DateDiff("n", [出勤時刻], "18:00")/60-1)*[時間単価]+DateDiff("n", "18:00", [退勤時刻])/60*[時間単価]*1.25,
            DateDiff("n", [出勤時刻], "18:00")/60*[時間単価]+DateDiff("n", "18:00", [退勤時刻])/60*[時間単価]*1.25
        ),
        IIf(
            [勤務時間]>6,
            [時間単価]*([勤務時間]-1)*1.25,
            [時間単価]*[勤務時間]*1.25
        )
    )
)

算術関数

Access2003応用
練習問題(P69)

追加課題:
算術関数を使用して,以下の表示を行う.

1.受験者数
2.平均点
3.最高得点
4.最少得点
5.65点以上75点未満の受験者数



2011年11月8日火曜日

フィールドのカウント(Dcount関数)

Access2003応用
練習問題(P69)

追加課題:
「T会員マスター」テーブル中の神奈川県の会員数をカウントし,フォームとして表示せよ.

1.「T会員マスター」テーブルの会員NO,名前,住所1を表示するフォームを作成する.
(テキストボックス作成時は,メニューの「表示」→「ツールボックス」を使用します)

2.フッターに神奈川県の会員数を表示するために,テキストボックスを用意し,
テキストボックスの「プロパティ」→「データ」タブ→「コントロールソース」
に関数を設置.


3.フォームビューで,正しく会員数が表示されていることを確認.


解答例
=DCount(
    "会員NO",
    "T会員マスター",
    "Left([住所1],4)='神奈川県'"
)