摘要:
分析需求 就是要把 一张表中的数据 通过不同的计算方法得到不同的列 而且 这张表还要和其他的表进行关联刚开始想这问题时 是怎么也想不出来 也不知道什么原因 竟然弄出来了select a.hometeamid as team,(select count(*) from match z where z.Status=2 and z.liansaiid=3) as total,(select count(*) from match as d where a.hometeamid=d.hometeamid and d.FirstHomeScores + d.SecondHomeScores = 0 o 阅读全文
posted @ 2012-02-07 20:08
水草肃
阅读(201)
评论(0)
推荐(0)
摘要:
今天在写一个sql 的时候可能是写的少的原因 花了好长的时间现在吧代码贴出来 大家一起看看select team.name tname,sum(c.none) as none ,sum(c.one) as one,sum(c.two) as two,sum(c.three) as three,sum(c.four) as four,sum(c.five) as five from ( select * from (select hometeamid tid,sum(case when FirstHomeScores + SecondHomeScores = 0 then 1 else 0 e. 阅读全文
posted @ 2012-02-07 20:01
水草肃
阅读(922)
评论(0)
推荐(0)
摘要:
在字段类型为int类型的时候我们取平均值可能 会出现一个问题就是无论怎么取值,结果都不带小数。或者无法正确的表示值小于零的情况。 这个时候我们可以*1.0 让原来的int类型带上小数 (数据库会自动进行转化),然后我们要将所得到的数据进行数据类型的转换 顺便控制它的显示格式例如cast(avg(a* 1.0+secondawayscores * 1.0+b* 1.0+c* 1.0) as decimal(9,2))decimal( , )和长度和精度有关。 阅读全文
posted @ 2012-02-07 19:49
水草肃
阅读(406)
评论(0)
推荐(0)