简体   繁体   English

通过对单列中的相同值进行分组来选择多个结果?

[英]Select multiple result by grouping same values from single column?

I am creating an email alert to send out three email separately from the below table:我正在创建电子邮件警报以分别从下表中发送三封电子邮件:

|**ID** |**Name**      |**Company**    |**Count**|            
|1      |John          |Apple          |2        |
|2      |Bill          |Microsoft      |2        |
|3      |Steve         |Apple          |2        |
|4      |Elon          |Tesla          |1        |
|5      |Satya         |Microsoft      |2        |

I desire to get all three different result to send the email separately我希望获得所有三个不同的结果以分别发送电子邮件

|**ID** |**Name**      |**Company**    |   
|1      |John          |Apple          |   
|3      |Steve         |Apple          |

AND 

|**ID** |**Name**      |**Company**    |
|2      |Bill          |Microsoft      |
|5      |Satya         |Microsoft      |

AND

|**ID** |**Name**      |**Company**    |
|4      |Elon          |Tesla          |

How could I get the desired result as above in SQL?如何在 SQL 中获得上述所需的结果?

SELECT * FROM your_table ORDER BY Company;

This query will help you:此查询将帮助您:

SELECT * FROM table_name WHERE COMPANY="company_name"

just replace company_name by Apple, Microsoft, or Tesla.只需将company_name替换为 Apple、Microsoft 或 Tesla。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM