房天下 > 房天下问答 > 业主生活 > 其他
  • sql 分组统计

    一个表有内容和时间字段然后我想查询某个份 每天的信息比如过 7月1号 1条数据 第一行显示7月1号第二行显示 7月1号那条数据如果6月9号 2条数据 第一行显示6月9号第二行显示 6月9号的2条数据如下图最好 SQL 实现 不行的话 C# Web 代码也可以

    提问者:q259d

    发布于2011-01-20

共1个回答
  • yanhai15 丨Lv 2
    如果表的记录量不大的话假设表名是test1 内容字段名是lname 时间字段名是hire_dateSQL语句实现:select b.lname from (select distinct datename(year,hire_date)+'-'+ datename(month,hire_date)+'-'+ case when day(hire_date) between 1 and 9 then '0'+datename(day,hire_date) else datename(day,hire_date) end lname, hire_date from test1union allselect lname, hire_date from test1 ) b order by b.hire_date,b.lname
    +1 2011-01-21 举报
热门人气推荐
免责声明:问答内容均来源于互联网用户,房天下对其内容不负责任,如有版权或其他问题可以联系房天下进行删除。