1) create a database Test. mdb
2) import the data tables of info. mdb and info1.mdb, which are info and info1 respectively. The table data is as follows:
The code is as follows: |
Copy code |
Info ----- Product Name 1234 2345 Info1 --------- Product Name vendor price 1234 vendors 1 10 1234 Manufacturers 2 20 1234 manufacturers 3 30 2345 manufacturers 1 40 2345 Manufacturers 2 50 2345 manufacturers 3 60 3456 manufacturers 1 70 3456 Manufacturers 2 80 3456 manufacturers 3 90
|
3) Create a new query and open the SQL View (View> SQL view)
4) paste the following content and run
The code is as follows: |
Copy code |
SELECT info1. name, Max (info1. price) AS price maximum, Min (info1. price) AS price minimum FROM info1 Group by info1. HAVING info1. name in (SELECT info. Name FROM info ); |
5) the running result is as follows:
The code is as follows: |
Copy code |
Query 1: select query ------------ Product Name Price-maximum price-minimum 1234 30 10 2345 60 40 |
Tutorial function supplement
MAX () function
The MAX function returns the maximum value in a column. NULL values are not included in calculation.
SQL MAX () syntax
Select max (column_name) FROM table_name note: MIN and MAX can also be used in text columns to obtain the highest or lowest values in alphabetical order.
MIN () function
The MIN function returns the minimum value in a column. NULL values are not included in calculation.
SQL MIN () syntax
Select min (column_name) FROM table_name note: MIN and MAX can also be used in text columns to obtain the highest or lowest values in alphabetical order.