ããã¼ã¿ãã¼ã¹ã¯ãã¨ã¦ã便å©ãªãã¼ã«ã§ããæ§ã
ãªåéã§åºã使ããã¦ãã¾ããä»åã¯ç°¿è¨ã¸ã®å¿ç¨ãåãæ±ãããã¨æãã¾ããããããæ¥å¸¸æ§ã
ãªåå¼ãåæãã¦ä»è¨³ãè¡ããã¨ã¯äººéã®ä»äºã§ããããã¼ã¿ãã¼ã¹ã®å½¹å²ã¯ä»è¨³ãçµãã£ã¦ãããæ¬é çºæ®ã§ããAIåãé²ãã§ããä»è¨³ã¯ã¾ãã¾ã 人éãããã¹ãä»äºã®ããã§ãã
ç®æ¬¡
è¨å¸³ã®èªåå
ãä»è¨³ãçµãã£ã¦ããååå®å£åº§ã¸è»¢è¨ãããã¨ãèªååãããã¨æãã¾ããããã¯
ã»ä»è¨³ã§æ示ãããåå®å£åº§ã®ãã¼ãã«ããåå¨ããªããã°ä½æããã
ã»ä½æãããããããã¯æ¢åã®åå®å£åº§ã®ãã¼ãã«ã«ãä»è¨³ã®æ示éãã«æ¥ä»ãç¸ææ¹ã®åå®ç§ç®ãéé¡ã転è¨ããã
ã»ä»è¨³ã®æ示éãã«è»¢è¨ã§ãããã©ããã確èªãããã表示ããã
è¥æããã°ã©ãã¼å¿
èªï¼ï¼åã§ç解ã§ããERå³ã®æ¸ãæ¹ï¼ã¹ãããï½ãã³ã¢ãã¸ãã¹ï½NTTã³ãã¥ãã±ã¼ã·ã§ã³ãº æ³äººã®ã客ãã¾
ãâãã¿ãããã¦ä¸ããããã¼ã¿ãã¼ã¹ãè¨è¨ããããã«ã¯ãããããªç¨èªãã¨ã³ãã£ãã£ãããã¢ããªãã¥ã¼ãããããªã¬ã¼ã·ã§ã³ã·ãããããã«ã¼ãã£ããªãã£ããä½ããæ½è±¡çãªè¨èãç»å ´ãã¾ãã
ããã¨ã³ãã£ãã£ãã¯ãã¼ã¿ãã¼ã¹ã§ã¯ãã¼ãã«ãã¨ã¯ã»ã«ã§ã¯ã¯ã¼ã¯ã·ã¼ããæ°å¦ã§ã¯{ }ã«ç¸å½ãã¾ãã容å¨ã§ããã
ããã¢ããªãã¥ã¼ããã¯ãã¼ã¿ãã¼ã¹ã§ã¯ã¬ã³ã¼ã(è¡)ãã¬ã³ã¼ãå
ã®ã«ã©ã (å)ãã¨ã¯ã»ã«ã§ã¯ã»ã«(ã¬ã³ã¼ãã¯ç¯å²æå®ã§å®ç¾)ãæ°å¦ã§ã¯é¨åéåãè¦ç´ ã§ãããã{ }ã®ä¸ã«å
¥ããã®ã§ãã
ãæ®ãã®ããªã¬ã¼ã·ã§ã³ã·ãããã¨ãã«ã¼ãã£ããªãã£ãã¯æ¬¡ã®ããã°ã©ã ã§èª¬æãã¾ãã
import sqlite3
conn = sqlite3.connect("Cosmos.db", isolation_level=None)
c=conn.cursor()
sql="SELECT name FROM sqlite_master WHERE TYPE ='table'"
for rec in c.execute(sql):
ããprint(t)
print()
while(True):
ããprint("è¨å¸³ãçµäºãã¾ããï¼")
ããnum=input('0ã§çµäº:')
ããif num == '0':
ããããbreak
ããprint("æ¥ä» åå®ç§ç® éé¡ åå®ç§ç® éé¡")
ãã#UI
ããdate=input('æ¥ä»:')
ããtitle1=input('åå®ç§ç®:')
ããprice1=input('éé¡:')
ããtitle2=input('åå®ç§ç®:')
ããprice2=input('éé¡:')
ãã#åå®å£åº§å(ãã¼ãã«å)
ããaccount1="åæ¹"+title1
ããaccount2="貸æ¹"+title2
ãã#åæ¹ãã¼ãã«ã®ä½æ
ããif date != ' ' and title1 != ' ' and price1 != ' ':
ããããsql="CREATE TABLE IF NOT EXISTS "
ããããsql+=account1
ããããsql+="( æ¥ä» DATE,åå®ç§ç® VARCHAR(20),éé¡ INTEGER)"
ããããc.execute(sql)
ãããã#åæ¹ãã¼ãã«ã¸ã®è»¢è¨
ããããsql="INSERT INTO "
ããããsql+=account1
ããããsql+=" (æ¥ä»,åå®ç§ç®,éé¡) VALUES (?,?,?)"
ããããuser=(date,title2,price1)
ããããc.execute(sql,user)
ãããã#åæ¹ãã¼ãã«ã®ç¢ºèª
ããããprint(account1)
ããããselect="SELECT * FROM "+account1
ããããfor rec in c.execute(select):
ããããããprint(rec)
ãã#貸æ¹ãã¼ãã«ã®ä½æ
ããif date != ' ' and title2 != ' ' and price2 != ' ':
ããããsql="CREATE TABLE IF NOT EXISTS "
ããããsql+=account2
ããããsql+="( æ¥ä» DATE,åå®ç§ç® VARCHAR(20),éé¡ INTEGER)"
ããããc.execute(sql)
ãããã#貸æ¹ãã¼ãã«ã¸ã®è»¢è¨
ããããsql="INSERT INTO "
ããããsql+=account2
ããããsql+=" (æ¥ä»,åå®ç§ç®,éé¡) VALUES (?,?,?)"
ããããuser=(date,title1,price2)
ããããc.execute(sql,user)
ãããã#貸æ¹ãã¼ãã«ã®ç¢ºèª
ããããprint(account2)
ããããselect="SELECT * FROM "+account2
ããããfor rec in c.execute(select):
ããããããprint(rec)
conn.commit()
conn.close()
ãããªã¬ã¼ã·ã§ã³ã·ãããã¯åå®ç§ç®ã®ã«ã©ã ãä¸ã®ããã°ã©ã ã§ã¯title1, title2ãäºãã«ç¸æåå®ãæã示ããã¨ã§é¢ä¿æ§ã表ç¾ãã¾ãã確ãã«è¡¨ç¾ã§ããã®ã§ããããã®é¢ä¿ã¯ä¸å¯¾ä¸ã®å¯¾å¿é¢ä¿ã¨ã¯éãã¾ãããããã§ãã«ã¼ãã£ããªãã£ããç»å ´ãã¾ãã
ããã«ã¼ãã£ããªãã£ãã¯ããé³¥ã®è¶³ãã¨ãå¼ã°ãã¾ããä¸å¯¾ä¸ã®å¯¾å¿é¢ä¿ã«ããã¨ãããé³¥ã®è¶³ãã®å½¢ã«ã¯ãªãã¾ãããããããã¹ãã§ããããã¾ããã¯ããã¾ãããããããã©ããã¦ããé³¥ã®è¶³ãã®å½¢ã«ãªããã¨ãããã¾ãããããã諸å£ãã§ããä¸å¯¾å¤ã®é¢ä¿ã«ãªã£ãããå¤å¯¾ä¸ã®é¢ä¿ã«ãªã£ããâ¦ã
ãä¸ã®NTTã³ãã¥ãã±ã¼ã·ã§ã³ãºæ§ã®ãµã¤ãã§ã¯ããããã®ä»ã«ãã¦ã¼ã¹ã±ã¼ã¹ãã¨ãããã®ãåºã¦ãã¾ããã©ã®ã¿ã¤ãã³ã°(ã¤ãã³ã)ã§ãã©ãããå¦çãè¡ãããã®ããã¨ãã£ããã¨ãè¨è¿°ãã¾ãããããã¯ã¨ã¦ãéè¦ã§ãããã®ã½ããã¦ã§ã¢ã®ä½¿ç¨ä¸ã®æ³¨æã§ããã¨ããåæ±ã説ææ¸ã®å
ã«ãªããã®ã§ããDXåãé²ãããã¦ãã¾ãããã¨ã¯ã»ã«çã使ãä»äºã¯ãã®ã¹ãã«ãæã£ãå±äººçãªãã¨ãå¤ãã§ãããããã®äººã転å¤ãããã©ãã§ãããï¼å¼ãç¶ãã®éã«å£ã§èª¬æããããã§ããããï¼
ãå³ç¤ºåã§ãããã®ã¯åºæ¥ãã ãå³ç¤ºåããã»ããããã§ããããç¾èã¯ä¸è¦ã«å¦ããã
ããã©ã³ã¹èª:Voir, c'est croire.
ãã¤ã¿ãªã¢èª:Vedere per crédere.
ãã¹ãã¤ã³èª:Ver es creer.
ãã§ããããå³ã§ãªãã¦ã表ã§ãããã§ãã
åæ¹ã¨è²¸æ¹ãã¼ãã«ãä½ãã¨ã â»å³ã®ä¾ã§ã¯åæ¹ä»å
¥ãã¼ãã« ã«2024-12-25,ç¾é,100ãã 貸æ¹ç¾éãã¼ãã«ã«åä¸æ¥ä» ã®2024-12-25,ä»å
¥,100ãã è¨å¸³ããã¾ããããããã |
æ¥ä»:2024-12-25â©ï¸ åå®ç§ç®:ä»å
¥â©ï¸ã éé¡:100â©ï¸ããã åå®ç§ç®:ç¾éâ©ï¸ã éé¡:100â©ï¸ããã |
åæ¹ãã¼ãã«ã®ã¿ä½ãã¨ã â»å³ã®ä¾ã§ã¯åæ¹ä»å
¥ãã¼ãã« ã«2024-12-25,諸å£,100ã è¨å¸³ããã¾ããããããã |
æ¥ä»:2024-12-25â©ï¸ åå®ç§ç®:ä»å
¥â©ï¸ã éé¡:100â©ï¸ããã åå®ç§ç®:諸å£â©ï¸ã éé¡:â©ï¸ããããã |
貸æ¹ãã¼ãã«ã®ã¿ä½ãã¨ã â»å³ã®ä¾ã§ã¯è²¸æ¹å£²ä¸ãã¼ãã« ã«2024-12-25,諸å£,100ã è¨å¸³ããã¾ããããããã |
æ¥ä»:2024-12-25â©ï¸ åå®ç§ç®:諸å£â©ï¸ã éé¡:â©ï¸ããããã åå®ç§ç®:売ä¸â©ï¸ã éé¡:100â©ï¸ããã |
ãä¸ã®ããã°ã©ã ã§
ããif date != ' ' and title1 != ' ' and price1 != ' ':
ããããsql="CREATE TABLE IF NOT EXISTS "
ããããsql+=account1
ãã¨ãªã£ã¦ããã¨ãããããã¾ããæ¥ä»ãåå®ç§ç®ãéé¡ã®3ç¹ã»ãããæããªããã°ãã¼ãã«ãä½ããªããã¨ãããã¨ã§ããããã¯ãã»ã¢ã«ã¬ã³ã®æ³åã使ã£ã¦
ããif date == ' ' or title1 == ' ' or price1 == ' ':
ããããsql="CREATE TABLE IF NOT EXISTS "
ããããsql+=account1
ãã¨ãæ¸ãã¾ããå
¥åé
ç®ã®ãã¡ãã©ããä¸ã¤ã§ã空æ¬ã§ããã¨å¦çãã¾ããããã¨ãããã¨ã§ãããé常ã¯ã以ä¸ã§ããããã§ããããï¼ãã¨ã確èªããå¿
è¦ãªã¨ããã§ããã
ããããä»è¨³ã¨åããå®å
¨ã«AIåãããã¨ã¯é£ããã¨æãã¾ããã¨ããã®ã¯ç¾å®ã«çºçããç¾è±¡ãªããäºè±¡ãªããææ¡ãç解ãã¦ä»è¨³ããããæ°å¼ã«ç¿»è¨³ãããã¨ãæ©æ¢°ã«ã¯é£ããã®ã§ããã©ããã£ã¦æ©æ¢°ã«å¦ç¿ããããããã®ã§ããããï¼äººéã§ããã°ã¾ãç¾è±¡ãªãäºè±¡ãªãã次ã®ããã«ãæç« é¡ãã«ç½®æãããã¨ãå¯è½ã§ãã
ãããèåå·¥æ¿ã§2種é¡ã®åæA(å°éº¦ç²)ãB(ãã¿ã¼)ã使ã£ã¦2種é¡ã®ãèåX,Yãä½ã£ã¦ãã¾ãããã®å·¥æ¿ã®çç£è½åã¯ãèåXã«ã¤ãã¦ã¯æç£2500åã¾ã§ããèåYã«ã¤ãã¦ã¯æç£1200åã¾ã§ã§ãããèåXã1åä½ãã«ã¯ãA(å°éº¦ç²)ã0.004è¢ãB(ãã¿ã¼)ã0.002ç®±ããèåYã1åä½ãã«ã¯ãA(å°éº¦ç²)ã0.006è¢ãB(ãã¿ã¼)ã0.008ç®±å¿
è¦ã§ãã1ãµæéã«ä»å
¥ãããã¨ã®ã§ããA(å°éº¦ç²)ã¯æ大14è¢ãB(ãã¿ã¼)ã¯æ大12ç®±ã§ãããèåX1åãããã®å©çã5åããèåY1åãããã®å©çã10åã¨ãã¦ãæéå©çãæ大ã«ããã«ã¯ããèåX,Yã®æéçç£åæ°ããããã«ããã°ããã§ããããã
ãã¨ããæç« é¡ãæ°å¼ã«ç½®æãã¦ã¿ã¾ãããã
ãã¾ãããèåXã®æç£åæ°ãå°æåã®xã¨ããã¨æç£2500åã¾ã§ã§ããã
ãx ⦠2500 ã»ã»ã»â
ã次ã«ãèåYã®æç£åæ°ãå°æåã®yã¨ããã¨æç£1200åã¾ã§ã§ããã
ãy ⦠1200 ã»ã»ã»â¡
ããã®æ¬¡ã¯â¦ãã¡ãã¤ã¨è¤éãªã®ã§è¡¨ã«ãã¦æ´çãã¦ã¿ã¾ãããã
 |
xåããã |
yåããã |
æ大é |
A(å°éº¦ç²) |
0.004x |
0.006y |
14è¢ |
B(ãã¿ã¼) |
0.002x |
0.008y |
12ç®± |
ããã®è¡¨ãåæ¹å(縦)ã«è¦ãã¨æç« é¡éãã§ãããèåXã1åããããA(å°éº¦ç²)0.004è¢ã¨B(ãã¿ã¼)0.002ç®±ã ããxåãããã ã¨xåã«ãªãããã§ããé£ã®yåããããåæ§ã«A(å°éº¦ç²)0.006è¢ã¨B(å°éº¦ç²)0.008ç®±ãyåããã¦ãã¾ãã
ã次ã«è¡æ¹å(横)ã«è¦ãã¨ãA(å°éº¦ç²)ã®1ãµæã®ä½¿ç¨éãã0.004xè¢ + 0.006yè¢ã§ãããæ大ã§14è¢ãªã®ã§
ã0.004x + 0.006y ⦠14 ã»ã»ã»â¢
ãåæ§ã«B(ãã¿ã¼)ã«ã¤ãã¦
ã0.002x + 0.008y ⦠12 ã»ã»ã»â£
ãæå¾ã¯å©çã®å¼
ã5x + 10y = i ã»ã»ã»â¤
ãããããã¤ã³ãã§ããâ ï½â£ã®ä¸çå¼(inequality)ã¨ç°ãªããæ¹ç¨å¼(equation)ã§ãããã¨ãä¸ã¤ãå³è¾ºã®iã¯åç(intercept)ã表ãã¦ãã¾ããéä¸(inter)ã§æã¾ãã(cept)ããããã§ããä½ãæã¾ãããã¨ããã¨ãæ¹ç¨å¼ã®è¡¨ãç´ç·(straight line)ã§ããyåçã¨xåçã§æãããããã¨ç·å(line segment)ã«ãªãã¾ããlineã¯ç·å½¢(linear)ããªãã³ãªã©åèªæºã§ããããã¦å¹³é¢(plane)ã¯ç´ç·ã«ãã£ã¦åå¹³é¢(half plane)ãã¤ã«åãããã¾ããä¸çå¼ã®è¡¨ãé å(domain,region)ã¯ãã®ãã¡ã®ããããã§ããâ ï½â£ãé£ç«ããã¨ãã®å
±éé¨åãæ±ãããã¾ããâ¤ã¨ãé£ç«ãããã«ã¯ãç´ç·ã®å¾ã(inclination of a lineããããã¯åã«slope)ã-1/2ã§ãããã¨ã¯åãã£ã¦ãã¾ãããiã®å¤ããã®å ´åyåçã§ããããããä¸å®ãªã®ã§å³ã«ãã£ã¦è§£ããã¨ã«ãªãã¾ãã
<div style="width: 400px;"><canvas id="canvas1">< /canvas ></div>
<p>
<script>
const canvas = document.getElementById('canvas1');
const ctx1 = canvas.getContext("2d");
ctx1.strokeStyle='#000000';
ctx1.beginPath();
ctx1.moveTo(50,0);
ctx1.lineTo(50,canvas.height);
ctx1.moveTo(0,canvas.height-20);
ctx1.lineTo(canvas.width,canvas.height-20);
ctx1.moveTo(50,canvas.height-70);
ctx1.lineTo(250,canvas.height-20);
ctx1.moveTo(50,canvas.height-100);
ctx1.lineTo(167,canvas.height-20);
ctx1.stroke();
ctx1.fillStyle='#ffff00';
ctx1.beginPath();
ctx1.moveTo(51,canvas.height-60);
ctx1.lineTo(89,canvas.height-60);
ctx1.lineTo(120,canvas.height-51);
ctx1.lineTo(130,canvas.height-40);
ctx1.lineTo(130,canvas.height-21);
ctx1.lineTo(51,canvas.height-21);
ctx1.lineTo(51,canvas.height-60);
ctx1.fill();
ctx1.fillStyle='#000000';
ctx1.font = "10px serif";
ctx1.fillText("7000/3", 15, 53);
ctx1.fillText("1500", 20, 85);
ctx1.fillText("1200", 20, 95);
ctx1.fillText("2500", 115,
canvas.height-10);
ctx1.fillText("3500", 150,
canvas.height-10);
ctx1.fillText("6000", 240,
canvas.height-10);
</script>
</p>
ãä¸ã®å³ãã©ã®ããã«ãã¦æããã®ããHTMLãè¼ãã¦ããã¾ããmoveTo()ã¯canvasããæµ®ããããã³ãããã§éããã¤ã¡ã¼ã¸ã§å§ç¹ã§ããlineTo()ã¯canvasã«ç½®ãããã³ãããã¾ã§åããã¤ã¡ã¼ã¸ã§ããç´ç·ã®æç»çµäºã¯stroke()ã§ãã
ãé»è²ã®é åã®æç»ã¯fillStyle()ã§è²ãæå®ããä¸çæ¸ãã§é åãä½ãfill()ãå®è¡ãã¾ããæ°å¤ãæåã¯fillText()ã使ãã¾ãããstrokeText()ã使ãã¨ä¸æãæåã«ãªãã¾ãã
ãæç»ã®ä»æ¹ããåããã«ãªã£ããã¨ã¨æãã¾ãã®ã§è§£èª¬ã«ç§»ãã¾ãã
ãä¸ã®å³ã§é»è²ã®é åãâ ï½â£ã®é£ç«ä¸çå¼ã®è¡¨ãé åã§ããxãâ§ã0, y ⧠0ã®é åã ãã§èãã¾ãããã
ãx ⦠2500 ã»ã»ã»â
ãããã¯x軸ã§2500ã¨æ¸ãããã¨ããããå·¦ã®é åã§ãã
ãy ⦠1200 ã»ã»ã»â¡
ãããã¯y軸ã§1200ã¨æ¸ãããã¨ããããä¸ã®é åã§ãã
ã0.004x + 0.006y ⦠14 ã»ã»ã»â¢
ãããã¯x = 0ã¨ããã¨y ⦠14/0.006 = 7000/3
ãy = 0ã¨ããã¨x ⦠3500
ãããã¯yåçã7000/3ãxåçã3500ã®ç´ç·ã®ä¸ã®é åã§ãã
ã0.002x + 0.008y ⦠12 ã»ã»ã»â£
ãããã¯x = 0ã¨ããã¨y ⦠1500
ãy = 0ã¨ããã¨x ⦠6000
ãããã¯yåçã1500ãxåçã6000ã®ç´ç·ã®ä¸ã®é åã§ãã
ããããã®å
±éé¨åãä¸ã®å³ã®é»è²ã®é¨åã§ãã¡ãã£ã¨ãã³ã¤ãªå
è§å½¢ã«ãªã£ã¦ãã¾ããå³ä¸ã®é ç¹(2ã¤ã®ç´ç·ã®äº¤ç¹)ã®åº§æ¨ã¯ \begin{eqnarray} \begin{bmatrix} 0.004 & 0.006 \\ 0.002 & 0.008 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 14 \\ 12 \end{bmatrix}\end{eqnarray}ãã®è§£ã(2000,1000)ã§ããããã¦æçµçãªçµè«ã§ãããå©çãæ大ã«ããç¹ããããªã®ã§ãã
ãâ¤ã®è¡¨ãå¾ã-1/2ã®ç´ç·ãyåçiãæ大ã«ãã¹ãä¸ããä¸ãã£ã¦ãããé»è²ã§ç¤ºããé åã¨å
±éé¨åãæã¤éçããã®ç¹ã§ããæç« é¡ã®çãã¯
ããèåX 2000åããèåY 1000åã®ã¨ãå©çæ大ã¨ãªãã¾ããããã¨â¤ãã
ã5 Ã 2000 + 10 Ã 1000 = 20000å
ããå©çæ大ã§ãã
ããã®ã¨ãã®ã°ã©ããæãããã«ã¯
ã5x + 10y = 20000
ãã®ä¸¡è¾ºãå®æ°é
ã®20000ã§å²ã£ã¦\begin{eqnarray}\frac{x}{4000} + \frac{y}{2000} = 1\end{eqnarray}ã¨å¤å½¢ããã¨ãxåçã4000ãyåçã2000ã¨æ±ã¾ãã¾ãã
ãç·å½¢è¨ç»æ³ã®èª¬æã¨ãã¦ã¯ä»¥ä¸ã§ãããããã«ãã¦ãå©çã20000åã¨ã¯å°ãªããã¾ãã
ãå°éº¦ç²1è¢30kgã§6000åããã¿ã¼1ç®±200gã§500åã¨ä»®å®ããã¨ãä»å
¥å¤(åå¾å価)ã¯
 |
ãèåX |
ãèåY |
A(å°éº¦ç²) |
120g(24å) |
180g(36å) |
B(ãã¿ã¼) |
0.4g(1å) |
1.6g(4å) |
åè¨ |
120.4g(25å) |
181.6g(40å) |
ãã¨ãªãããããã5åã10åã®ãã¼ã¸ã³ãä¸ä¹ãããã¨ã売価ã¯30åã50åã§ããå¶ç´æ¡ä»¶ã®å°éº¦ç²14è¢ã¾ã§ããã¿ã¼12ç®±ã¾ã§ãã¨ããã®ãä¾çµ¦éçãªãå¤ä¸ãããããã¾ããããèªç¤¾ã®çç£è½åã«èµ·å ããã®ãªããå·¥æ¿ã®åºããè¨åã人å¡æ°ãªã©æ¤è¨ã§ãã¾ããããã£ãä»å
¥éã100åã®å°éº¦ç²1400è¢ããã¿ã¼1200ç®±ã¨ããã®ãå¯è½ã§ããå©çã100åã®200ä¸åã§ãããã®ããã«ããããèããã®ã¯ã財åãã®åéã§ããåå¼å
ãå¢ããã§ããããããã¨ç°¿è¨ã®ã»ãã§ãåãªã人ååå®ã§ã¯æ¸ã¾ãªããªããã顧客管çã·ã¹ãã ãã®æ§ç¯ãå¿
è¦ã¨ãªãã¾ããããã¯ä¸ã®NTTã³ãã¥ãã±ã¼ã·ã§ã³ãºæ§ã®ãµã¤ããã覧ä¸ãããå種ã®ãã¹ã¿ãã¼ãã«çããããè¤éã§ããã
ãã¼ãªã©
[主ãã¼(primary key)]
ãããã¯IDã¨èããã¨ããã§ããããä¾ãã°ãââãã¹ã¿ãã¼ãã«ã§åæ§ååã®äººç©ãåä¸åã®åå·ãæã¤ä¼æ¥ã転å¤ã移転ãããããã¨ä½æå¤æ´ã®éã«ç¹å®ãã¥ããã®ã§å¥ã«ã«ã©ã ãè¨ãã¦ç¹å®åããããããããã§ãããã ããããã空æ¬(' ')ã§ããã¨å¹æãªãã§ããã
ãã¨ããã§ä»è¨³å¸³(daybook DB D.B.)ã«ã¯IDãè¦å½ããã¾ãããIDãããã°
UPDATE ä»è¨³å¸³ SET ç¸æåå®='ç¾é' WHERE ID='2056'
ããªã©ã¨ä¿®æ£å¯è½ã§ãããç°¿è¨ã§ã¯è¨é²ã¯è¨é²ã¨ãã¦æ®ããä¿®æ£ä»è¨³ã§å¯¾å¿ãããã¨ã«ãªã£ã¦ãã¾ãã
[å¤é¨ãã¼(foreign key)]
ããããããªã¬ã¼ã·ã§ã³ã·ãããå®ç¾ãããã®ã§ããç°¿è¨ã§ã¯ç¸æåå®ç§ç®ãããã§ãããä»è¨³å¸³ã«ããå
ä¸æ¬ã¯ç·åå®å
帳(general ledger)ã®ãã¼ã¸æ°ã¨ãªã¬ã¼ã·ã§ã³ã·ãããããã®ã§å¤é¨ãã¼ã§ãã
[ãã¥ã¼(view)]
ãç·åå®å
帳(general ledger)ãªã©ã¯ãã¼ãã«ã§ä½æãããã¨ãã§ãã¾ãããVIEWã§ä½æããã»ããããã§ããããå
ã®æç« é¡ã®ä¾ãæãä¸ãã¾ãã
ãï¼æ¥ã®çç£é: èåX 200åãèåY 100å
ã5æ¥ãã¨ã«5æ¥å売ãä¸ãããã¨ã«ããã¨
ãèåX:30000å(1000Ã@30å)
ãèåY:25000å(500Ã@50å)
ãâ´å£²ä¸åè¨:55000å
ãå°éº¦ç²æ¶è²»é: 200Ã120 + 100Ã180 = 42000g
ã5æ¥ãã¨ã«ä»å
¥ãããã¨ã«ããã¨
ã5Ã42000 = 210kg = 7è¢(30kgå
¥ã@6000å)
ããã¿ã¼æ¶è²»é: 200Ã0.4 + 100Ã1.6 = 240g
ã5æ¥ãã¨ã«ä»å
¥ãããã¨ã«ããã¨
ã5Ã240 = 1200g = 6ç®±(200gå
¥ã@500å)
ãâ´ä»å
¥åè¨:45000å
ãä»å
¥ã売ä¸ã4ååè¨å¸³ãã¾ããã
select="SELECT * FROM åæ¹ä»å
¥ FULL OUTER JOIN 貸æ¹ç¾é ON åæ¹ä»å
¥.æ¥ä»=貸æ¹ç¾é.æ¥ä»"
for rec in c.execute(select):
ããprint(rec)
print()
ãã®çµæã¯
('2024-12-01', 'ç¾é', 45000, '2024-12-01', 'ä»å
¥', 45000)
('2024-12-06', 'ç¾é', 45000, '2024-12-06', 'ä»å
¥', 45000)
('2024-12-11', 'ç¾é', 45000, '2024-12-11', 'ä»å
¥', 45000)
('2024-12-16', 'ç¾é', 45000, '2024-12-16', 'ä»å
¥', 45000)ãæ¢ã«ãã¼ã¿ãå
¥ã£ã¦ããåæ¹ä»å
¥ãã¼ãã«ã¨è²¸æ¹ç¾éãã¼ãã«ãå®å
¨å¤é¨çµåãã¦ããã ãã§ããæ°ãã«ãã¼ãã«ãä½ãå¿
è¦ã¯ããã¾ããã
select="SELECT * FROM åæ¹ä»å
¥ FULL OUTER JOIN 貸æ¹å£²ä¸ ON åæ¹ä»å
¥.æ¥ä»=貸æ¹å£²ä¸.æ¥ä»"
for rec in c.execute(select):
ããprint(rec)
print()
ããã®çµæã¯
('2024-12-01', 'ç¾é', 45000, '2024-12-01', 'ç¾é', 55000)
('2024-12-06', 'ç¾é', 45000, '2024-12-06', 'ç¾é', 55000)
('2024-12-11', 'ç¾é', 45000, '2024-12-11', 'ç¾é', 55000)
('2024-12-16', 'ç¾é', 45000, '2024-12-16', 'ç¾é', 55000)
ã次ã®é·ãSELECTæã¯ããã«ãã®æ¬¡ã®VIEWã®å
ã«ãªããã®ã§ãã
select="SELECT strftime('%Y-%m',貸æ¹å£²ä¸.æ¥ä») AS 'æ¥ä»','売ä¸é«',SUM(貸æ¹å£²ä¸.éé¡) AS '売ä¸é«','åå¾å価',SUM(åæ¹ä»å
¥.éé¡) AS 'åå¾å価','売ä¸ç·å©ç(ç²å©ç)',SUM(貸æ¹å£²ä¸.éé¡ - åæ¹ä»å
¥.éé¡) AS '売ä¸ç·å©ç','å©çç', SUM(貸æ¹å£²ä¸.éé¡ - åæ¹ä»å
¥.éé¡) * 100 / SUM(貸æ¹å£²ä¸.éé¡) AS 'å©çç' FROM åæ¹ä»å
¥ FULL OUTER JOIN 貸æ¹å£²ä¸ ON åæ¹ä»å
¥.æ¥ä» = 貸æ¹å£²ä¸.æ¥ä» GROUP BY strftime('%Y-%m',貸æ¹å£²ä¸.æ¥ä»)"
for rec in c.execute(select):
ããprint(rec)
print()
ããã®çµæã¯
('2024-12', '売ä¸é«', 220000, 'åå¾å価', 180000, '売ä¸ç·å©ç(ç²å©ç)', 40000, 'å©çç', 400)
ããããVIEWã®å®ç¾©ã§ããæçè¨ç®ã¨ããååãã¤ãã¾ããã
sql="CREATE VIEW IF NOT EXISTS æçè¨ç® AS SELECT strftime('%Y-%m',貸æ¹å£²ä¸.æ¥ä») AS 'æ¥ä»','売ä¸é«',SUM(貸æ¹å£²ä¸.éé¡) AS '売ä¸é«','åå¾å価',SUM(åæ¹ä»å
¥.éé¡) AS 'åå¾å価','売ä¸ç·å©ç(ç²å©ç)',SUM(貸æ¹å£²ä¸.éé¡ - åæ¹ä»å
¥.éé¡) AS '売ä¸ç·å©ç','å©çç', SUM(貸æ¹å£²ä¸.éé¡ - åæ¹ä»å
¥.éé¡) * 100 / SUM(貸æ¹å£²ä¸.éé¡) AS 'å©çç' FROM åæ¹ä»å
¥ FULL OUTER JOIN 貸æ¹å£²ä¸ ON åæ¹ä»å
¥.æ¥ä» = 貸æ¹å£²ä¸.æ¥ä» GROUP BY strftime('%Y-%m',貸æ¹å£²ä¸.æ¥ä»)"
c.execute(sql)
select="SELECT * FROM æçè¨ç®"
for rec in c.execute(select):
ããprint(rec)
print()
ããã®çµæã¯
('2024-12', '売ä¸é«', 220000, 'åå¾å価', 180000, '売ä¸ç·å©ç(ç²å©ç)', 40000, 'å©çç', 18)
ãã¨ãªã£ã¦ããããããã¼ãã«ã®ããã«ä½¿ç¨ã§ãã¾ãã次ã¯ã*(ã¢ã¹ã¿ãªã¹ã¯)ã®ãããã«ç¹å®ã«ã©ã ãé¸æãããã®ã§ãã
select="SELECT æ¥ä», å©çç FROM æçè¨ç®"
for rec in c.execute(select):
ããprint(rec)
('2024-12', 18)
#[QPython] Press enter to exit ...
ãä¸ç¨®ã®çä¼¼ãã¼ãã«ã§èªã¿è¾¼ã¿ã ãå¯è½ãæ¸ãè¾¼ã¿ä¸å¯ã§ããã¾ããsqlite3ã§ã¯ã§ãã¾ããããOracleãªã©ã§ã¯VIEWã«æ¨©é(GRANT)ãä»ä¸ã§ãã¦ãç¹å®ã®è
ããèªã¿è¾¼ã¿ã§ããªããã¨ãã£ã使ç¨æ³ãããã¾ãã
ã¾ã¨ã
ããç°¿è¨ä¸ã®åå¼ãã¨ãããã®ãããã¾ãã
æ°æ³192æ¡ãããã«ç¶ã193æ¡ã§ã¯çé£ãéºå¤±ãããåå¼ã§ããç°¿è¨ã§ãããã§ããæ¥å¸¸æè¦ã¨ã¯éãã¾ããç°¿è¨ã§ã¯ãã¾ããç°¿è¨ä¸ã®åå¼ããã©ãããè¦æ¥µãããã¨ããå§ã¾ãã¾ãããããæåã®ãä»è¨³ãã§ãããããã®å¾ç´°ããä»è¨³ãè¡ãã¾ãããã¼ã¿ãã¼ã¹ã使ç¨ããããããã¯æä½æ¥ã§è»¢è¨ããã®ã¯ãã®å¾ã®ãã¨ã§ãã