mySQL は簡単ですが、タスクを実行してテーブルを正確に表示する方法を論理的に理解しようとするのが初めての場合は特に、複雑になる可能性があります。
私の宿題の質問は次のように述べています:各企業は何回面接をしましたか?最初に最も多くのインタビューを受けた企業を印刷し、次に会社名で AZ 順に並べ替えます。
+------------------------------+------------+
| companyname | Interviews |
+------------------------------+------------+
| Ajax Software, Inc. | 2 |
| Cameron Industries | 2 |
| Flordia Software Designs | 2 |
| Manhattan-Made Software | 2 |
| Mountainside Magic Software | 2 |
| Acme Information Source | 1 |
| ApplDesign | 1 |
<<<<<<< cut out some output >>>>>>>>>>>>>>>>>>>
| Vegas Programming and Design | 1 |
| Virginia Software Industries | 1 |
+------------------------------+------------+
23 rows in set (0.00 sec)
これをコーディングすることで、最初の列を完全に取得しました。
SELECT DISTINCT companyname,
FROM interview
ORDER BY companyname ASC;
しかし、インタビューでは、会社名に、インタビュー側にインクリメントするまったく同じ文字列を持つ企業がいくつあるのか、コードを取得しようとしています。これはどのように作動しますか?
フル出力:
+------------------------------+
| companyname |
+------------------------------+
| Acme Information Source |
| Ajax Software, Inc. |
| Ajax Software, Inc. |
| ApplDesign |
| Bay Software Inc. |
| Braddock Information Assoc. |
| Buffalo Software Assoc. |
| Cameron Industries |
| Cameron Industries |
| CCC Software |
| Davis-Klein Software |
| DC Security Applications |
| Flordia Software Designs |
| Flordia Software Designs |
| Focused Applications, Inc. |
| Georgia Software Design |
| Jersey Computer Services |
| Long Island Apps, Inc. |
| Manhattan-Made Software |
| Manhattan-Made Software |
| Mountainside Magic Software |
| Mountainside Magic Software |
| Nantucket Applications, Inc. |
| PennState Programming, Inc. |
| Rochester Software Design |
| Sandy Hook Software |
| Vegas Programming and Design |
| Virginia Software Industries |
+------------------------------+
28 rows in set (0.00 sec)