易截截图软件、单文件、免安装、纯绿色、仅160KB

[MySQL]求一句SQL

数据结构大概是这样:

日期      部门      营业额
09-20    部门1    100
09-20    部门2    200
09-20    部门3    300
09-19    部门2    400
09-19    部门4    500
……

大概是这么个样子。需要计算出每天营业额最高的部门及其营业额。以前好象写过这种东西,不过后来因为被SQL SERVER的排名函数惯坏了,现在完全不记得了。请各位指点指点小弟,不尽感激
SQL code:
select * from yourTable a
where not exists (select 1 from yourTable where 日期=a.日期 and 营业额>a.营业额);


SQL code:

select 部门,sum(营业额) 总营业额
from 表名
group by 部门
order by 总营业额 desc
limit 1;



或者

SQL code:
select a.*
from yourTable a inner join (select 日期,max(营业额) as max_营业额 from yourTable group by 日期) b
on a.日期=b.日期 and a.营业额=b.max_营业额


SQL code:

mysql> select * f


相关问答:

mysql 简单问题

假如数据库中有个test表,表中有id,Name,num,记录时间
id为自增长主键,name是名字,num表示其数量

1  nike  100        系统时间
2  nike  300  &n ......

Mysql连接oracle

需要在MySQL里面写个储存过程,
访问oracle的数据.
目前不能

oracle可以就可以连接mysql,通过odbc+dblink来连接

没有办法。目前的MYSQL的版本中尚不支持连接到其它数据库,

真挺有想法的 目前我没做过 ......

mysql 导致死机

环境:win2003 apache2 resin3 php5 mysql5
mysql错误里出现这个,服务器直接死到那里。
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_log ......

谁有MySQL安装包?

谁有MySQL安装包?发给我个网址...
http://dev.mysql.com/downloads/

http://dev.mysql.com/downloads/mysql/5.1.html

官方下载地址。

我不懂看英文咧

不用看懂,你直接找你要的版本就行了。
......

MySQL的ID 32768 问题

我是使用spring+hibernate +mysql的开发环境
使用annotation来配置Mysql的映射关系

bean如下:

@SuppressWarnings("serial")
@MappedSuperclass
public class PersistenceSupport ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号