--Select Database UseDotstudy--1) Extract some fieldsSelectArea, sales department, merchandise, sales, unit price, amount fromData--2) Extract all fields (*)Select * fromData--3) Extract non-repeating records (distinct)Select distinctArea fromDataSelect distinctArea, Sales Department fromData--4) AliasesSelectArea, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromDataSelectArea, Department=Sales department, goods, Sales, unit price, sales=Amount fromData--5) Extract top N Records (top)Select Top 3Area, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromData--6) Extract the previous n% record (top)Select Top Ten percentArea, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromData--7) Sort query (order by)SelectArea, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromDataOrder byAmountASC--AscendingSelectArea, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromDataOrder byAmountdesc--DescendingSelectArea, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromDataOrder byAmount--Default Ascending--Top 3 withdrawals from salesSelect Top 3Area, Sales Department asDepartment, commodity, Sales, unit price, amount asSales fromDataOrder byAmountdesc--8) Conditional query (where)--information in the amount above 1500Select * fromDatawhereAmount>= the--sales of information between 30 and 50Select * fromDatawhereSales>= - andSales<= -Select * fromDatawhereSalesbetween - and -
Simple query of 08_sql server