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 ...
随机推荐
- 32.使用来MethodFilterInterceptor灵活拦截
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 步骤一.建立MethodAction,代码如下: package com.a ...
- 记一次微信小程序开发
之前在网上看到博客园新闻服务开放接口,因为自己本身有看博客园IT新闻的习惯,为了能随时随地简洁方便的浏览新闻,于是萌生了一个利用开放API开发一个微信小程序的想法. 1. mpvue初探 平时技术栈有 ...
- Resources与StreamingAssets文件夹的区别
1.Resources文件夹 Resources文件夹是一个只读的文件夹,通过Resources.Load()来读取对象.因为这个文件夹下的所有资源都可以运行时来加载,所以Resources文件夹下 ...
- hibernate查询出的实体,set值后,自动更新到数据库
1.问题症状描述 最近在处理一个新需求问题,代码的大致逻辑是获取一个实体对象,调用该对象的set方法设置其中的某些字段,然后把修改后的实体作为参数供其他地方调用,根据返回值来决定是否更新这个 ...
- Xpath解析xml
Xpath解析xml其实最主要的是查找xml文档中信息,而且不需要了解xml文档结构 package com.huawei.xml; import java.io.InputStream;import ...
- cudnn 安装
ubuntu 下载地址 https://developer.nvidia.com/rdp/cudnn-download 安装教程 http://docs.nvidia.com/deeplearning ...
- archlinux错误:无法提交处理 (无效或已损坏的软件包)
1.首先更新一下密钥,如果没有安装archlinux-keyring,请及时安装 sudo pacman-key --refresh-keys 2.重新加载相应的签名密钥 sudo pacman-ke ...
- intellij idea15,SVN commit file提示No changes detected
备注:我用的intellij 15,已经配置了SVN.且我的工程是从SVN导出的 遇到的问题:Subversion提交代码时提示No changes detected,当然新文件想要add也是选项 ...
- 126. Word Ladder II( Queue; BFS)
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformat ...
- 28. Implement strStr() (String)
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle ...