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 ...
随机推荐
- Spring MVC 学习 之 - URL参数传递
在学习 Spring Mvc 过程中,有必要来先了解几个关键参数: @Controller: 在类上注解,则此类将编程一个控制器,在项目启动 Spring 将自动扫描此类,并进行对应URL路由映 ...
- python greenlet 背景介绍与实现机制
最近开始研究Python的并行开发技术,包括多线程,多进程,协程等.逐步整理了网上的一些资料,今天整理一下greenlet相关的资料. 并发处理的技术背景 并行化处理目前很受重视, 因为在很多时候,并 ...
- Richview 首页 奇偶页 不同页眉页脚
首页 奇偶页 不同页眉页脚 ScaleRichView v6.0 Different headers and footers for the first page, for odd and even ...
- 跟我学算法-tensorflow 实现卷积神经网络附带保存和读取
这里的话就不多说明了,因为上上一个博客已经说明了 import numpy as np import tensorflow as tf import matplotlib.pyplot as plt ...
- Java Web 从入门到精通(明日科技)
目录结构: 第一章:Java Web 应用开发概述 第二章:html与css网页开发基础 第三章:JavaScript脚本语言 第四章:搭建开发环境 第五章:JSP语言基础 第六章:JSP内置对象 第 ...
- Redis Key操作
[Redis Key操作] 1.GETSET key value 将给定 key 的值设为 value ,并返回 key 的旧值(old value). 当 key 存在但不是字符串类型时,返回一个错 ...
- awk编程基础
一.awk介绍 awk(名字来源于三个创始人姓氏首字母)是linux系统下文本编辑工具,是一门编程语言,有自己的基本语法和流程控制.函数.awk简单高效. 二.awk的运行方法 例子:使用冒号:分 ...
- Python3 sorted() 函数
Python3 sorted() 函数 Python3 内置函数 描述 sorted() 函数对所有可迭代的对象进行排序操作. sort 与 sorted 区别: sort 是应用在 list 上的 ...
- 26.Remove Duplicates from Sorted Array(Array)
Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...
- Qt Pro file
Qt keys qmake Manual Building Common Project Types #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...