SELECTæã®å¦çã®ä»çµã¿ã説æãã¦ã¿ãã
SQLã®SELECTæã¯é常ã«å¼·åã§ããSQLã使ãã¨è¤éãªå¦çãçãå½ä»¤ã§è¡ãããã¨ãããã¾ãã
ã§ãããè¤éãªå¦çãè¡ãSELECTæãæ¸ãããã«ã¯ãSELECTæã®å¦çã®ä»çµã¿ããã¡ãã¨ç解ãã¦ããå¿
è¦ãããã¾ãã
ããã§ãä»åã¯SELECTæã®å¦çã®ä»çµã¿ããå
é¨çãªå¦çæé ãä»®å®ãã¦èª¬æãã¦ã¿ã¾ãã*1
ãªããä»åã¯ä¸ã¤ã®ãã¼ãã«ã«å¯¾ããå¦çã®ã¿ã説æãã¾ããè¤æ°ãã¼ãã«ã®çµåã¯èª¬æãã¾ããã
ç®æ¬¡
- SELECTæã®å¦çã®åºæ¬ã
- SELECTæã®å¦çã¯äºã¤ã«åããããã
- ãã¼ãã«ãä¸è¡ãã¤å¦çããã
- æ¡ä»¶ã«å½ã¦ã¯ã¾ãè¡ãåºåããã
- åºåé ç®ãç·¨éãã
- è¤éãªæ¡ä»¶ãæå®ãã
- åºåçµæã並ã¹æ¿ããã
- ãã¼ãã«å
ã®è¤æ°ã®è¡ãéç´ããã
- ãã¹ã¦ã®è¡ãéç´ããã
- ã°ã«ã¼ãæ¯ã«éç´ããã
SELECTæã®å¦çã®åºæ¬ã
SELECTæã®å
é¨çãªå¦çã®åºæ¬ã¯ããã¼ãã«ã®åè¡ã«å¯¾ããç¹°ãè¿ãå¦çã§ãã
ããã§ããç¹°ãè¿ãå¦çã¯ãä»ã®ããã°ã©ãã³ã°è¨èªã§ã®è¨è¿°ãããããªç¹°ãè¿ãå¦çã®ãã¨ã§ãã以ä¸ã¯ä»ã®ããã°ã©ãã³ã°ã§è¨è¿°ããç¹°ãè¿ãå¦çã®ä¾ã§ãã
<> // ãã¹ã¦ã®è¡ã«ã¤ãã¦ç¹°ãè¿ãã for ( int i = 0; i < rows.length; ++i ) { // 対象ã®è¡ãå¦çããã someProcess( rows[i] ); } < > // ãã¹ã¦ã®è¡ã«ã¤ãã¦ç¹°ãè¿ãã for ( $i = 0; $i < count( $rows ); ++$i ) { // 対象ã®è¡ãå¦çããã some_process( $rows[$i] ); }
以éã§ã¯ããã®ç¹°ãè¿ãå¦çã念é ã«ç½®ãã¦èª¬æãã¦ããã¾ãã
SELECTæã®å¦çã¯äºã¤ã«åããããã
SELECTæã®å¦çã¯å¤§ã¾ãã«ä»¥ä¸ã®äºã¤ã«åãããã¾ãããã®äºã¤ã®å¦çã¯å¤§ããç°ãªããããåºå¥ãããã¨ã¯é常ã«éè¦ã§ãã
- ãã¼ãã«ãä¸è¡ãã¤å¦çããã
- ãã¼ãã«å ã®è¤æ°ã®è¡ãéç´ããã
äºã¤ã®ãã¡ãã©ã¡ãã®å¦çãè¡ããããã¯ä»¥ä¸ã§å¤æã§ãã¾ãã
- SELECTå¥ã§éç´é¢æ°ã使ããªãå ´åããã¼ãã«ã¯ä¸è¡ãã¤å¦çããã¾ãã
- SELECTå¥ã§éç´é¢æ°ãä¸ã¤ã§ã使ã£ãå ´åããã¼ãã«å ã®è¤æ°ã®è¡ãéç´ãè¡ããã¾ãã
ããã§ã主è¦ãª5ã¤ã®éç´é¢æ°ãæãã¾ãã
- AVG - å¹³åå¤ãæ±ãã
- COUNT - åæ°ãæ±ãã
- MAX - æ大å¤ãæ±ãã
- MIN - æå°å¤ãæ±ãã
- SUM - åè¨ãæ±ãã
ãã¼ãã«ãä¸è¡ãã¤å¦çããã
ãã¼ãã«ã®ä¸è¡ãã¤ã®å¦çã説æãã¾ããSELECTå¥ã§éç´é¢æ°ã使ããªãå ´åããã®å¦çãè¡ããã¾ãã
æ¡ä»¶ã«å½ã¦ã¯ã¾ãè¡ãåºåããã
SELECTå¥ãFROMå¥ãWHEREå¥ã使ãã¨ããã¼ãã«ããæ¡ä»¶ã«å½ã¦ã¯ã¾ãè¡ã ããåå¾ã§ãã¾ãã
SELECT date, product, price /* (3) */ FROM sales /* (1) */ WHERE price > 100 /* (2) */
ãã®SELECTæã®å¦çã¯ã以ä¸ã®ãããªæé ã§è¡ããã¾ãã
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ã®ãdateãããproductãããã¦ãpriceãã®å¤ãåºåããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
3. 2è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
4. 2è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
5. 3è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
6. 3è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
7. 4è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
8. 4è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
9. 5è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+----------+--------------+-------+ | date | product | price | +----------+--------------+-------+ | 20090316 | æ¶ãã´ã | 150 | | 20090313 | æ¶ãã´ã | 150 | | 20090316 | éçåã | 1000 | +----------+--------------+-------+
åºåé ç®ãç·¨éãã
SELECTå¥ã§æ¼ç®åãé¢æ°ã使ãã¨ãåºåé ç®ã®ç·¨éãè¡ãã¾ããããã«ãasã使ã£ã¦å¦ççµæã®ååãæå®ã§ãã¾ãã
SELECT /* (3) */ concat(date, "ã®", product, "ã®å£²ä¸" ) as description, /* (3)-1. */ price * quantity as amount /* (3)-2. */ FROM sales /* (1) */ WHERE price > 100 /* (2) */
ãã®SELECTæã®å¦çã¯ã以ä¸ã®ãããªæé ã§è¡ããã¾ãã
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ããã¨ã«ãdescriptionãã¨ãamountããåºåããã
(3)-1. ãdescriptionãã¯ããdateãã®å¤ããã®ãããproductãã®å¤ããã®å£²ä¸ããé£çµãããã®ã¨ããã
(3)-2. ãamountãã¯ããpriceãã®å¤Ããquantityãã®å¤ã¨ããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
3. 2è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
4. 2è¡ç®ããã¨ã«ãdescriptionãã¨ãamountããåºåããã ⦠(3)
4-1. ãdescriptionãã¯ããdateãã®å¤ããã®ãããproductãã®å¤ããã®å£²ä¸ããé£çµãããã®ã¨ããã ⦠(3)-1
â ã20090316ã®æ¶ãã´ã ã®å£²ä¸ã
4-2. ãamountãã¯ããpriceãã®å¤Ããquantityãã®å¤ã¨ããã ⦠(3)-2
â ã45000ã
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
5. 3è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
6. 3è¡ç®ããã¨ã«ãdescriptionãã¨ãamountããåºåããã ⦠(3)
6-1. ãdescriptionãã¯ããdateãã®å¤ããã®ãããproductãã®å¤ããã®å£²ä¸ããé£çµãããã®ã¨ããã ⦠(3)-1
â ã20090313ã®æ¶ãã´ã ã®å£²ä¸ã
6-2. ãamountãã¯ããpriceãã®å¤Ããquantityãã®å¤ã¨ããã ⦠(3)-2
â ã15000ã
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
7. 4è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
8. 3è¡ç®ããã¨ã«ãdescriptionãã¨ãamountããåºåããã ⦠(3)
8-1. ãdescriptionãã¯ããdateãã®å¤ããã®ãããproductãã®å¤ããã®å£²ä¸ããé£çµãããã®ã¨ããã ⦠(3)-1
â ã20090316ã®éçåãã®å£²ä¸ã
8-2. ãamountãã¯ããpriceãã®å¤Ããquantityãã®å¤ã¨ããã ⦠(3)-2
â ã20000ã
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
9. 5è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+----------------------------------+--------+ | description | amount | +----------------------------------+--------+ | 20090316ã®æ¶ãã´ã ã®å£²ä¸ | 45000 | | 20090313ã®æ¶ãã´ã ã®å£²ä¸ | 15000 | | 20090316ã®éçåãã®å£²ä¸ | 20000 | +----------------------------------+--------+
è¤éãªæ¡ä»¶ãæå®ãã
WHEREå¥ã§æ¼ç®åãé¢æ°ãçµã¿åãããã¨ãè¤éãªæ¡ä»¶å¤å®ãè¡ãã¾ãã
SELECT date, product, price /* (3) */ FROM sales /* (1) */ WHERE price * quantity = 20000 and substring(date, 5, 4) = "0316" /* (2) */
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ã®ãdateãããproductãããã¦ãpriceãã®å¤ãåºåããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã ⦠(2)
3. 1è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
4. 2è¡ç®ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
5. 3è¡ç®ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
6. 4è¡ç®ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã ⦠(2)
7. 4è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
8. 5è¡ç®ãæ¡ä»¶ãprice * quantity = 20000 and substring(date, 5, 4) = "0316"ããæºãããã¨ã確èªããã ⦠(2)
9. 5è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+----------+-----------------+-------+ | date | product | price | +----------+-----------------+-------+ | 20090316 | ãã¼ã«ãã³ | 100 | | 20090316 | éçåã | 1000 | +----------+-----------------+-------+
åºåçµæã並ã¹æ¿ããã
ORDER BYå¥ã使ãã¨ãSELECTå¥ã®åºåçµæã並ã¹æ¿ãããã¨ãã§ãã¾ãã
SELECT date, product, price /* (3) */ FROM sales /* (1) */ WHERE price > 100 /* (2) */ ORDER BY date /* (4)ã¨(5) */
ãã®SELECTæã®å¦çã¯ã以ä¸ã®ãããªæé ã§è¡ããã¾ãã
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ã®ãdateãããproductãããã¦ãpriceãã®å¤ãä¸æãã¼ãã«ã«åºåããã
(4) ä¸æãã¼ãã«ããdateãããã¼ã«ãã¦ä¸¦ã¹æ¿ããã
(5) ä¸æãã¼ãã«ã®å 容ãåºåããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
3. 2è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
4. 2è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
5. 3è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
6. 3è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
7. 4è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
8. 4è¡ç®ã®ãdateãããproductãããã¦ãpriceããåºåããã ⦠(3)
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
9. 5è¡ç®ãæ¡ä»¶ãprice > 100ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶æºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
ããã¾ã§ã®ã¨ãããä¸æãã¼ãã«ã«ã¯ä»¥ä¸ãåºåããã¦ãã¾ãã
<<ä¸æãã¼ãã«>> +----------+--------------+-------+ | date | product | price | +----------+--------------+-------+ | 20090316 | æ¶ãã´ã | 150 | | 20090313 | æ¶ãã´ã | 150 | | 20090316 | éçåã | 1000 | +----------+--------------+-------+
10. ä¸æãã¼ãã«ããdateãããã¼ã¨ãã¦ä¸¦ã¹æ¿ããã ⦠(4)
ããã¾ã§ã®ã¨ãããä¸æãã¼ãã«ã«ã¯ä»¥ä¸ãåºåããã¦ãã¾ãã
<<ä¸æãã¼ãã«>> +----------+--------------+-------+ | date | product | price | +----------+--------------+-------+ | 20090313 | æ¶ãã´ã | 150 | | 20090316 | æ¶ãã´ã | 150 | | 20090316 | éçåã | 1000 | +----------+--------------+-------+
11. ä¸æãã¼ãã«ã®å 容ãåºåããã ⦠(5)<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+----------+--------------+-------+ | date | product | price | +----------+--------------+-------+ | 20090313 | æ¶ãã´ã | 150 | | 20090316 | æ¶ãã´ã | 150 | | 20090316 | éçåã | 1000 | +----------+--------------+-------+
ãã¼ãã«å ã®è¤æ°ã®è¡ãéç´ããã
ãã¼ãã«å ã®è¤æ°ã®è¡ãéç´ããå¦çã説æãã¾ããSELECTå¥ã§éç´é¢æ°ãä¸ã¤ã§ã使ã£ãå ´åããã®å¦çãè¡ããã¾ãã
ãã¹ã¦ã®è¡ãéç´ããã
GROUP BYå¥ãæå®ããã«éç´é¢æ°ã使ãã¨ããã¼ãã«ã®ãã¹ã¦ã®è¡ãéç´ããã¾ãã
SELECT /* (7) */ SUM(price*quantity) /* (4)ã(6) */ as sum_of_amount /* (7)-1. */ FROM sales /* (1) */ WHERE product = "æ¶ãã´ã " /* (2) */
ãã®SELECTæã®å¦çã¯ã以ä¸ã®ãããªæé ã§è¡ããã¾ãã
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ãä¸æãã¼ãã«ã«åºåããã
(4) SUM(price*quantity)ç¨ã®å¤æ°ãç¨æããã
(5) ä¸æãã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(6)ãç¹°ãè¿ãã
(6) SUM(price*quantity)ç¨ã®å¤æ°ã«ã対象ã®è¡ã®ãpriceãã®å¤Ããquantityãã®å¤ãå ç®ããã
(7) ãsum_of_amountããåºåããã
(7)-1. ãsum_of_amountãã¯ãSUM(price*quantity)ç¨ã®å¤æ°ã®å 容ã¨ããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)<<対象è¡:1è¡ç®>>
+------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶ãæºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
3. 2è¡ç®ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã ⦠(2)
4. 2è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
5. 3è¡ç®ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã ⦠(2)
6. 3è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
7. 4è¡ç®ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶ãæºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
9. 5è¡ç®ãæ¡ä»¶ãproduct = "æ¶ãã´ã "ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶ãæºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
ãã®ã¨ããä¸æãã¼ãã«ã«ã¯ä»¥ä¸ãåºåããã¦ãã¾ãã
<<ä¸æãã¼ãã«>> +------------+----------+--------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+--------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+--------------+-------+----------+
10. SUM(price*quantity)ç¨ã®å¤æ°ãç¨æããã ⦠(4)
âSUM(price*quantity)ç¨ã®å¤æ° ï¼ 0
11. ä¸æãã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(6)ãç¹°ãè¿ãã ⦠(5)
<<対象è¡:1è¡ç®>> +------------+----------+--------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+--------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | +------------+----------+--------------+-------+----------+
12. SUM(price*quantity)ç¨ã®å¤æ°ã«ã対象ã®è¡ã®ãpriceãã®å¤Ããquantityãã®å¤ãå ç®ããã ⦠(6)
âSUM(price*quantity)ç¨ã®å¤æ° ï¼ 0 ï¼ 150 à 300 ï¼ 45000
<<対象è¡:2è¡ç®>> +------------+----------+--------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+--------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+--------------+-------+----------+
13. SUM(price*quantity)ç¨ã®å¤æ°ã«ã対象ã®è¡ã®ãpriceãã®å¤Ããquantityãã®å¤ãå ç®ããã ⦠(6)
âSUM(price*quantity)ç¨ã®å¤æ° ï¼ 45000 ï¼ 150 à 100 ï¼ 60000
14. ãsum_of_amountããåºåããã ⦠(7)
14-1. ãsum_of_amountãã¯ãSUM(price*quantity)ç¨ã®å¤æ°ã®å
容ã¨ããã ⦠(7)-1.<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+---------------+ | sum_of_amount | +---------------+ | 60000 | +---------------+
ã°ã«ã¼ãæ¯ã«éç´ããã
GROUP BYå¥ãæå®ãã¦éç´é¢æ°ã使ãã¨ããã¼ãã«ã®è¡ãã°ã«ã¼ãã«åããããã°ã«ã¼ãæ¯ã®éç´ãè¡ããã¾ãã
SELECT /* (10) */ product, /* (10)-1. */ SUM(quantity) /* (7)ã(9) */ as sum_of_qunatity /* (10)-2. */ FROM sales /* (1) */ WHERE product <> "éçåã" /* (2) */ GROUP BY product /* (3)ã(6) */
ãã®SELECTæã®å¦çã¯ã以ä¸ã®ãããªæé ã§è¡ããã¾ãã
(1) ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã
(2) 対象ã®è¡ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã
âæ¡ä»¶ãæºãããªãå ´åã次ã®è¡ã®å¦çã«é²ãã
(3) 対象ã®è¡ãä¸æãã¼ãã«ã«åºåããã
(4) ä¸æãã¼ãã«ããproductãããã¼ã¨ãã¦ä¸¦ã¹æ¿ããã
(5) ä¸æãã¼ãã«ã®è¡ããã¼ãproductãã®å¤ã§ã°ã«ã¼ãã«åããã
(6) ä¸æãã¼ãã«ã®å ¨ã¦ã®ã°ã«ã¼ãã«ã¤ãã¦(7)ã(10)ãç¹°ãè¿ãã
(7) SUM(quantity)ç¨ã®å¤æ°ãç¨æããã
(8) 対象ã®ã°ã«ã¼ãã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(9)ãç¹°ãè¿ãã
(9) SUM(quantity)ç¨ã®å¤æ°ã«ã対象ã®è¡ã®ãquantityãã®å¤ãå ç®ããã
(10) ãproductãã¨ãsum_of_quantityããåºåããã
(10)-1. ãproductãã¯ãã°ã«ã¼ãã®ãã¼ãproductãã®å¤ã¨ããã
(10)-2. ãsum_of_quantityãã¯ãSUM(quantity)ç¨ã®å¤æ°ã®å 容ã¨ããã
ä¾ã¨ãã¦ã以ä¸ã®ãsalesããã¼ãã«ã«ãã®æé ããã¦ã¯ãã¦ã¿ã¾ãã
<<ãsalesããã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | | 0000000004 | 20090316 | éçåã | 1000| 20 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
<<æé éå§>>
1. ãsalesããã¼ãã«ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(2)ã¨(3)ãç¹°ãè¿ãã ⦠(1)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
2. 1è¡ç®ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã ⦠(2)
3. 1è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150| 300 | +------------+----------+-----------------+-------+----------+
4. 2è¡ç®ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã ⦠(2)
5. 2è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
<<対象è¡:3è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150| 100 | +------------+----------+-----------------+-------+----------+
6. 3è¡ç®ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã ⦠(2)
7. 3è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
<<対象è¡:4è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000004 | 20090316 | éçåã | 1000| 20 | +------------+----------+-----------------+-------+----------+
8. 4è¡ç®ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã ⦠(2)
âæ¡ä»¶ãæºãããªãã®ã§ã次ã®è¡ã®å¦çã«é²ãã
<<対象è¡:5è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100| 200 | +------------+----------+-----------------+-------+----------+
9. 5è¡ç®ãæ¡ä»¶ãproduct <> "éçåã"ããæºãããã¨ã確èªããã ⦠(2)
10. 5è¡ç®ãä¸æãã¼ãã«ã«åºåããã ⦠(3)
ãã®ã¨ããä¸æãã¼ãã«ã«ã¯ä»¥ä¸ãåºåããã¦ãã¾ãã
<<ä¸æãã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100 | 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100 | 200 | +------------+----------+-----------------+-------+----------+
11. ä¸æãã¼ãã«ããproductãããã¼ã¨ãã¦ä¸¦ã¹æ¿ããã ⦠(4)
ãã®ã¨ããä¸æãã¼ãã«ã«ã¯ä»¥ä¸ãåºåããã¦ãã¾ãã
<<ä¸æãã¼ãã«>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100 | 200 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100 | 200 | | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+-----------------+-------+----------+
12. ä¸æãã¼ãã«ã®è¡ããã¼ãproductãã®å¤ã§ã°ã«ã¼ãã«åããã ⦠(5)
ãã®ã¨ããä¸æãã¼ãã«ã¯ä»¥ä¸ã®ããã«ã°ã«ã¼ãåãããã¾ãã
<<ã°ã«ã¼ã1>> ãã¼ãproductãï¼ããã¼ã«ãã³ã +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100 | 200 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100 | 200 | +------------+----------+-----------------+-------+----------+ <<ã°ã«ã¼ã2>> ãã¼ãproductãï¼ãæ¶ãã´ã ã +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+-----------------+-------+----------+
13. ä¸æãã¼ãã«ã®å ¨ã¦ã®ã°ã«ã¼ãã«ã¤ãã¦(7)ã(10)ãç¹°ãè¿ãã ⦠(6)
<<対象ã°ã«ã¼ã:ã°ã«ã¼ã1>> ãã¼ãproductãï¼ããã¼ã«ãã³ã +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100 | 200 | | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100 | 200 | +------------+----------+-----------------+-------+----------+
14. SUM(quantity)ç¨ã®å¤æ°ãç¨æããã ⦠(7)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 0
15. ã°ã«ã¼ã1ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(9)ãç¹°ãè¿ãã ⦠(8)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000003 | 20090316 | ãã¼ã«ãã³ | 100 | 200 | +------------+----------+-----------------+-------+----------+
16. SUM(quantity)ç¨ã®å¤æ°ã«ã1è¡ç®ã®ãquantityãã®å¤ãå ç®ããã ⦠(9)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 0 ï¼ 200 ï¼ 200
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000001 | 20090313 | ãã¼ã«ãã³ | 100 | 200 | +------------+----------+-----------------+-------+----------+
17. SUM(quantity)ç¨ã®å¤æ°ã«ã2è¡ç®ã®ãquantityãã®å¤ãå ç®ããã ⦠(9)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 200 ï¼ 200 ï¼ 400
18. ãproductãã¨ãsum_of_quantityããåºåããã ⦠(10)
18-1. ãproductãã¯ãã°ã«ã¼ãã®ãã¼ãproductãã®å¤ã¨ããã ⦠(10)-1.
18-2. ãsum_of_quantityãã¯ãSUM(quantity)ç¨ã®å¤æ°ã®å
容ã¨ããã ⦠(10)-2.
<<対象ã°ã«ã¼ã:ã°ã«ã¼ã2>> ãã¼ãproductãï¼ãæ¶ãã´ã ã +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+-----------------+-------+----------+
19. SUM(quantity)ç¨ã®å¤æ°ãç¨æããã ⦠(7)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 0
20. ã°ã«ã¼ã2ã®ãã¹ã¦ã®è¡ã«ã¤ãã¦(9)ãç¹°ãè¿ãã ⦠(8)
<<対象è¡:1è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000005 | 20090316 | æ¶ãã´ã | 150 | 300 | +------------+----------+-----------------+-------+----------+
21. SUM(quantity)ç¨ã®å¤æ°ã«ã1è¡ç®ã®ãquantityãã®å¤ãå ç®ããã ⦠(9)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 0 ï¼ 300 ï¼ 300
<<対象è¡:2è¡ç®>> +------------+----------+-----------------+-------+----------+ | no | date | product | price | quantity | +------------+----------+-----------------+-------+----------+ | 0000000002 | 20090313 | æ¶ãã´ã | 150 | 100 | +------------+----------+-----------------+-------+----------+
22. SUM(quantity)ç¨ã®å¤æ°ã«ã2è¡ç®ã®ãquantityãã®å¤ãå ç®ããã ⦠(9)
âSUM(quantity)ç¨ã®å¤æ° ï¼ 300 ï¼ 100 ï¼ 400
23. ãproductãã¨ãsum_of_quantityããåºåããã ⦠(10)
23-1. ãproductãã¯ãã°ã«ã¼ãã®ãã¼ãproductãã®å¤ã¨ããã ⦠(10)-1.
23-2. ãsum_of_quantityãã¯ãSUM(quantity)ç¨ã®å¤æ°ã®å
容ã¨ããã ⦠(10)-2.<<æé çµäº>>
æçµçã«ã以ä¸ãåºåããã¾ãã
+-----------------+-----------------+ | product | sum_of_qunatity | +-----------------+-----------------+ | ãã¼ã«ãã³ | 400 | | æ¶ãã´ã | 400 | +-----------------+-----------------+