简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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