一个排名的SQL
select *, n=(select count(*) from scores where score>=a.score) from scores a order by nid score n
b 78 1
c 66 2
a 56 3谁能帮忙解释下,如何扫描出结果的吗?
谢谢!
select *, n=(select count(*) from scores where score>=a.score) from scores a order by nid score n
b 78 1
c 66 2
a 56 3谁能帮忙解释下,如何扫描出结果的吗?
谢谢!
2、where子句基于指定的条件对记录行进行筛选;
3、group by子句将数据划分为多个分组;
4、使用聚集函数进行计算;
5、使用having子句筛选分组;
6、计算所有的表达式;
7、使用order by对结果集进行排序。
另外:一个查询语句各个部分的执行顺序:
--8) SELECT (9) DISTINCT (11) <TOP_specification> <select_list>
--(1) FROM <left_table>
--(3) <join_type> JOIN <right_table>
--(2) ON <join_condition>
--(4) WHERE <where_condition>
--(5) GROUP BY <group_by_list>
--(6) WITH {CUBE | ROLLUP}
--(7) HAVING <having_condition>
--(10) ORDER BY <order_by_list>
select count(*) from scores where score>=a.score
得到的值与外面表比较
不知道怎么讲 具体看执行计划