mysq查询一年中每月最晚的一条数据!

[复制链接]
查看11 | 回复3 | 2012-3-16 11:13:09 | 显示全部楼层 |阅读模式
假设日期对应的字段为 v_date 所查询的表为 date_table 所查询年份为2011select *
from date_table
where date_table.v_datein
(select distinct max(v_date)
from date_table
group by to_char(v_date, 'yyyy-mm'))
and to_char(v_date, 'yyyy') = '2011';...
回复

使用道具 举报

千问 | 2012-3-16 11:13:09 | 显示全部楼层
select a.* from table a,(select to_char(rq, 'yyyy-mm') as rq,max(sl) as sl
from table
group by to_char(rq, 'yyyy-mm')) bwhere to_char(a.rq, 'yyyy-m...
回复

使用道具 举报

千问 | 2012-3-16 11:13:09 | 显示全部楼层
先给一条数据看看吧,表描述得不是很清楚...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行