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 ...
随机推荐
- 关于javascript中的typeof和instanceof介绍
typeof用来检测给定变量的数据类型 instanceof用来检测对象的类型 typeof用来检测给定变量的数据类型(也可叫做基本类型,基本数据类型.包含undefined.boolean.stri ...
- 设置 UILabel 和 UITextField 的 Padding 或 Insets (理解UIEdgeInsets)
转自http://unmi.cc/uilable-uitextfield-padding-insets 主要是理解下UIEdgeInsets在IOS UI里的意义. 靠,这货其实就是间隔,起个名字这么 ...
- spring security+cas(cas proxy配置)
什么时候会用到代理proxy模式? 举一个例子:有两个应用App1和App2,它们都是受Cas服务器保护的,即请求它们时都需要通过Cas 服务器的认证.现在需要在App1中通过Http请求访问App2 ...
- 文件上传:input file FileReader
js: window.onload = function () { var input = document.getElementById('input-file'), info = document ...
- 119. Pascal's Triangle II (Graph; WFS)
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...
- python爬虫如何POST request payload形式的请求
python爬虫如何POST request payload形式的请求1. 背景最近在爬取某个站点时,发现在POST数据时,使用的数据格式是request payload,有别于之前常见的 POST数 ...
- Visual Studio 2017 无法打开包括文件: “QOpenGLWidget”: No such file or directory
编译项目时,发现报错:VS 无法打开包括文件: “QOpenGLWidget”: No such file or directory,在Qt对应的目录(E:\Qt\Qt5.12.2\5.12.2\ms ...
- How to use Qt Designed Ui file
Ui Designed file In Working, we can use Qt Designer to designe UI; Then, use uic -o head.h designe.u ...
- DALSA网口线扫相机SDK开发详解例程(C#版)
首先吐槽一句,官方的demos写的真的不好,坑爹啊.对于小白来说,开发官方demos为我所用太难了.为什么呢?因为它Dalsa的DALSA.SaperaLT.SapClassBasic.dll中,不仅 ...
- Golang之Struct(二叉树定义)
接招吧,看代码: package main import "fmt" //二叉树结构体 //如果每个节点有两个指针,分别用来指向左子树和右子树,我们把这样的结构叫做二叉树 type ...