1. You need to import an Excel file to the database during work, and modify the relevant table to import it without mentioning it. [item change price] The imported execl table sales?price commodity price list
Update salesprice price
Set salesprice price. saleprice = change the price of the product. New Sales Price
, Sales#price. costprice = change the price of the product. New cost price
From salesprice price, product price change
Where cast (sales=price. Sid as varchar (20) = cast (item change price. No. As varchar (20 ))
In this way, a table is modified with the conditions and values of another table.
2. Two Ways to insert data into a temporary table
(1) Select... into # O from table insert data to the temporary table
(2) Insert into # O Select... from table insert data to the temporary table
The two differences are as follows: (1) You do not need to create a table structure first. A temporary table automatically creates a temporary table of this type based on the select Field and its type. (2) You need to create a table structure first, before you can insert data to a temporary table
3. Notes for grouping SQL statements
(1) Select top 1 * from Table order by T1 DESC, T2 DESC
(2) Select top 1 * from Table order by T1, T2 DESC
These two types of order by (2) have been used in many cases. Previously we thought it was based on the T1 and T2 fields for sorting from large to small. take one entry at work and sort it by two fields. If T1 is equal, use top1. (2) based on T2, but you will find that the problem is not correct. later, I asked why I knew the details of the period. order by is sorted by ASC by default. when t1 and t2 DESC are used, they are actually T1 ASC, T2 DESC, T1 DESC, and T2 DESC. I have never noticed before.