Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Gruppen generieren > Gruppieren auf einer einzelnen Spalte

Gruppieren auf einer einzelnen Spalte

Gruppierungen auf einer einzigen Spalte sind am einfachsten und am häufigsten. Wenn Sie sich beispielsweise für den Gesamtsaldo jedes Produkts interessieren, müssen Sie lediglich auf der Spalte account.product_cd gruppieren:

mysql> SELECT product_cd, SUM(avail_balance) prod_balance
    -> FROM account
    -> GROUP BY product_cd;
+------------+--------------+
| product_cd | prod_balance |
+------------+--------------+
| BUS        |      9345.55 |
| CD         |     19500.00 |
| CHK        |     73008.01 |
| MM         |     17045.14 |
| SAV        |      1855.76 |
| SBL        |     50000.00 |
+------------+--------------+
6 rows in set (0.00 sec)

Diese Abfrage generiert sechs Gruppen, nämlich für jedes Produkt eine, und bildet dann die Summe aller Zeilen in jeder Gruppe.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial