例如:我现在有这样一个表id int(10) 主键
goods_id int(10) 货物id
price varchar(10) 货物价格
date varcahr(10) 日期
有下面的数据:
id goods_id price date
1 001 109.7 20100507
2 001 201.6 20100409
3 001 1001.3 20100708要求选出最低价格的那一列,(注意 price 是 varchar 类型)
goods_id int(10) 货物id
price varchar(10) 货物价格
date varcahr(10) 日期
有下面的数据:
id goods_id price date
1 001 109.7 20100507
2 001 201.6 20100409
3 001 1001.3 20100708要求选出最低价格的那一列,(注意 price 是 varchar 类型)
解决方案 »
- 请高手帮忙优化一段代码(按特定条件进行排名,江苏高考用)
- msyql单表统计查询疑难问题
- 报错:Segmentation fault (core dumped)在编译安装mysql-5.1.9-beta.tar
- sqlite3一次插入多条记录出错
- 为什么mysql总提示错误?
- 自己写的程序运行在自己买的服务器上,最近发现mysql运行两三天后,速度会很慢直到死掉,我发现里面有很多locked和sleep进程导致的,这些
- 自己做的PHP+POSTGRES的论文管理系统,欢迎大家指正
- postgres如何写存储过程,望各位帮忙,给一个相关实例
- 求一sql语句,设置表a.col字段的值,等于 表b.col2 的值,但是是随机的,没有 类似a.id=b.id
- Mysql Insert into进行表之间数据复制的时候出现自增错误
- 如何设计这个数据库?
- 数据库开发这点事 中文PDF下载
'截至2010-04-14 18:57:37 用户结帖率0.00%
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
如果这样select * from 这样一个表 order by price+0 desc limit 1;
select * from tt a where not exists(select 1 from tt where a.goods_id=goods_id and 0+a.price>0+price)
select a.* from tt a inner join
(select goods_id ,min(0+price) as mi from tt group by goods_id) b
on a.goods_id=b.goods_id and 0+a.price=b.mi