order by 使用注意
create table user (
id int primary key,
name varchar(11) ,
depid int
);
create table dept(
id int primary key,
name varchar(11)
);
insert into user(id,name,depid) values(1,'zhangsan',1);
insert into user(id,name,depid) values(2,'lisi',1);
insert into user(id,name,depid) values(3,'wangwu',2);
insert into user(id,name,depid) values(4,'zhaosi',2);
insert into user(id,name,depid) values(6,'yy3',1);
insert into user(id,name,depid) values(7,'yy1',1);
insert into user(id,name,depid) values(8,'yy2',4);
insert into user(id,name,depid) values(9,'yy4',3);
insert into dept(id,name) values(1,'开发');
insert into dept(id,name) values(2,'测试');
insert into dept(id,name) values(3,'销售');
insert into dept(id,name) values(4,'前台');
insert into dept(id,name) values(5,'工程');
select u.id,u.name,u.depid,d.name "部门名称" from user u,dept d where u.depid=d.id group by d.id desc;

select u.id,u.name,u.depid,d.name "部门名称" from user u,dept d where u.depid=d.id group by d.id desc,u.id desc ;

group by后面必须有唯一性字段。
order by 使用注意的更多相关文章
- 在UPDATE中更新TOP条数据以及UPDATE更新中使用ORDER BY
		正常查询语句中TOP的运用: SELECT TOP 1000 * FROM MP_MemberGrade 随意更新一张表中满足条件的前N条数据: UPDATE TOP (1) MP_Member ... 
- BZOJ 1391: [Ceoi2008]order [最小割]
		1391: [Ceoi2008]order Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1509 Solved: 460[Submit][Statu ... 
- Android中的Libraries以及Order and Export的使用。
		1Add JAR 从Eclipse的现有所有工程中,添加jar包到该工程下 2Add External JARs 从Eclipse外的其他的位置,添加jar包到该工程下 3Add Variable 增 ... 
- linux 环境下运行STS时 出现must be available in order to run STS
		linux 环境下运行ECLIPSE时 出现 “ A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avai ... 
- order by  与  group by  区别
		order by 排序查询.asc升序.desc降序 示例: select * from 学生表 order by 年龄 ---查询学生表信息.按年龄的升序(默认.可缺省.从低到高)排列显示 也可以多 ... 
- 排序 order by 的用法
		order by 跟在select* from 后面 order by 默认的是升序, asc 升序 desc 降序 select * from 表名 order by 字段名 asc 在带有 ... 
- Oracle update和order by
		今天遇到一个关于SQL转换成Oracle语句的问题,描述如下: select * from emp order by deptno; select * from dept; Sql Server: u ... 
- Morris post order traversal algorithm
		Sept. 5, 2015 花时间把代码读明白, 比光看书强. 动手写代码, 改代码, 兴趣是最好的老师. 多记几个例子, 增加情趣. 举个例子关于中序遍历, 4 ... 
- Leetcode, construct binary tree from inorder and post order traversal
		Sept. 13, 2015 Spent more than a few hours to work on the leetcode problem, and my favorite blogs ab ... 
- [LeetCode] K-th Smallest in Lexicographical Order 字典顺序的第K小数字
		Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n. N ... 
随机推荐
- curl返回302 found问题相关
			在使用curl 的时候 ,偶尔会遇到一些URL跳转到新的URL,即HTTP中的3XX(redirection,重定向 ) 此时如果不设置自动跳转倒新url的话,可能会出现问题. 一些网上的解决方法: ... 
- WSAEvent
			[WSAEvent] 1.WSACreateEvent.创建WSA事件. 2.WSAEventSelect. lNetworkEvents [in] A bitmask that specifies ... 
- 数据库 alert.log 日志中出现 "[Oracle][ODBC SQL Server Wire Protocol driver][SQL Server] 'RECOVER'"报错信息
			现象描述: (1).数据库通过调用透明网络实现分布式事务,但透明网关停用后,失败的分布式事务并未清理. (2).数据库 alert 日志 Thu Sep 06 06:53:00 2018 Errors ... 
- 【poj2411】Mondriaan's Dream  状态压缩dp
			AC传送门:http://vjudge.net/problem/POJ-2411 [题目大意] 有一个W行H列的广场,需要用1*2小砖铺盖,小砖之间互相不能重叠,问有多少种不同的铺法? [题解] 对于 ... 
- 38-解决Fiddler查看Post参数中文乱码的问题
			转载自:https://blog.csdn.net/JusterDu/article/details/50888617 解决Fiddler查看Post参数中文乱码的问题 2016年03月14日 18: ... 
- 读写大“二进制”文件,不必申请很大内存(fopen,fread,fwrite,fclose)
			<?php /** * 读写大二进制文件,不必申请很大内存 * 只有读取到内容才创建文件 * 保证目录可写 * * @param string $srcPath 源文件路径 * @param s ... 
- FIX protocol tutorial : Fix Session is not connecting how to diagnose it ?
			In this blog post of FIX protocol tutorial series I would like to share my experience with connectiv ... 
- Redis 安装配制
			Redis 安装配制 redis 安装分为单机安装.伪集群安装.集群安装. Redis 下载地址:http://www.redis.cn/download.html Redis 在线测试工具:http ... 
- Spring boot——logback.xml 配置详解(四)<filter>
			阅读目录 1 filter的使用 2 常用的过滤器 文章转载自:http://aub.iteye.com/blog/1101260,在此对作者的辛苦表示感谢! 回到顶部 1 filter的使用 < ... 
- Basic4android v3.00 发布
			这次发布的版本主要是增加了快速debuger. 在运行时,可以在IDE 里面随时修改代码,而不需要重新发布应用. 大大提高了开发效率. Basic4android v3.00 is released. ... 
