最近遇到的SQL问题
2012-02-29 16:52
176 查看
select translator as '译者姓名',count(*) as '总派件次数',sum(convert(numeric(8,2),quantity)) as '总翻译字数',sum(case when DATEDIFF(mm,[date],getdate())<=6 then convert(numeric(8,2),quantity) else 0 end) as '近6个月派件字数', (sum(case when DATEDIFF(mm,[date],getdate())<=6 then convert(numeric(8,3),total) else 0 end)/sum(case when DATEDIFF(mm,[date],getdate())<=6 then convert(numeric(8,2),quantity) else 0 end))/0.14*100 as '近6个月平均得分' from t_paijian where unitprice!='dd' and total!='dd' and translation='英->中' Group by translator记录一下。
case when , datediff,convert,sum的用法都用了,原来自己也可以写这样的语句
相关文章推荐
- ASP MVC最近遇到的两个问题(SQL和HTTPWebRequest)
- sql去重问题(最近java笔试总遇到这个问题,忍不住要记录一下)
- 最近遇到的两个问题
- 最近遇到些问题
- 在Hive中执行DDL之类的SQL语句时遇到的一个问题
- 最近遇到的安卓问题总结
- 最近在用SDK写俄罗斯的时候遇到了很多问题 ...点亮GDI盲区值得看
- oracle数据库的sql平时遇到的一些小问题union,to_char(),null last,group by
- 总结最近项目开发中遇到的问题,希望对大家有所帮助!
- SQL 中遇到的KKK问题
- 最近遇到的还未解决的问题
- 最近遇到的一些小问题汇总
- SQL遇到的问题
- 【最近面试遇到的一些问题】JAVA UTF-8 GB2312 编码互转
- 最近遇到的一些问题总结
- 遇到 JDBC执行sql查询,报[列名无效]问题
- 开发中遇到的一个关于 SQL 语句执行的问题
- 最近遇到不少客户提出关于PP账户名字需要更改,如何更改的问题。因此在此做个简单的总结,希望能帮到一些朋友!
- 最近使用j2me所遇到的问题~
- 最近oracle开发中遇到的一些问题及解决办法(五)待续