#降序select*from tablesName where clientNo ='123'orderby salary desc;#升序(默认升序)select*from tablesName where clientNo ='123'orderby salary ;select*from tablesName where clientNo ='123'orderby salary asc;#对两个字段进行降序select*from tablesName where clientNo ='123'orderby salary desc,receiptNo desc;#将某个字段由字符转为数值,再对两个字段进行降序select*from tablesName where clientNo ='123'orderby salary desc,(receiptNo+0)desc;#先查找参考号,再根据参考号查找结算信息select* cl_tran_hist where reference in(select reference from cl_receipt where receipt_type = ‘PO’)orderby tran_date desc;#not in select Name as Customers from Customers where Id notin(select CustomerId from Orders)
1.1查询并统计出现的个数
--查询某个字段出现的次数select site,count(site) 次数 from a_cost
groupby site
orderbycount(site)desc--查询某个字段次数大于1的数据selectcount(site),site
from a_cost
groupby site
havingcount(site)>1--查询某个字段出现次数最多的数据selecttop1 site,count(site) 次数
from a_cost
groupby site
orderbycount(site)desc
1.查询命令1.1查询并排序#降序select * from tablesName where clientNo = '123' order by salary desc;#升序(默认升序)select * from tablesName where clientNo = '123' order by salary ;select * from tablesName where clientNo = '123' order by salary asc;#对两个字段进行降序select