In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "the use of mysql query sentences group by and order by". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the use of mysql query sentences group by and order by".
I forgot the details. The content is about as follows.
Two tables with the following contents:
Sql code
+-+
| | z_code | mgr | pigs | |
+-+
| | 021 | zhang | 85 | |
| | 010 | wang | 70 | |
+-+
2 rows in set
Query final result
Sql code
+-+
| | z_code | city | mgr | |
+-+
| | 010 | BJ | wang | |
| | 021 | HB | zhang | |
+-+
2 rows in set
Table A
Sql code
+-+
| | part | mgr | pigs | |
+-+
| | 001 | wang | 20 | |
| | 002 | wang | 50 | |
| | 011 | zhang | 49 | |
| | 012 | zhang | 36 | |
+-+
4 rows in set
Table B
The query statements used are:
Sql code
Select z_code, A.mgr mgr, sum (pigs) pigs from A, B where A.mgr = B.mgr group by A.mgr order by pigs desc
Here is the SQL for creating the table and inserting statements:
Sql code
Create database pig_store
Use pig_store
Create table A (
Z_code varchar (8)
City varchar (4)
Mgr varchar (16)
);
Create table B (
Part varchar (8)
Mgr varchar (16)
Pigs int (5)
);
Insert into A values ('010,' BJ', 'wang'), (' 021, 'HB',' zhang')
Insert into B values ('001,' wang', 20), ('002,' wang', 50), ('011,' zhang', 49), ('012,' zhang', 36)
Thank you for your reading, the above is the content of "the use of mysql query sentences group by and order by". After the study of this article, I believe you have a deeper understanding of the use of mysql query sentences group by and order by, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.