是不是这样:select 日期,sum(case when typeid='饮料' then 数量 else 0 end ) as 饮料
,sum(case when typeid='主食' then 数量 else 0 end ) as 主食
from 销售日志 group by 日期自己关联销售日志和货物信息表,以及处理日期等
,sum(case when typeid='主食' then 数量 else 0 end ) as 主食
from 销售日志 group by 日期自己关联销售日志和货物信息表,以及处理日期等
解决方案 »
- sql server能不能更改服务器名称
- 寻求集装箱装载Bay位图的数据库解决方案
- 累加排序老问题!
- 家里两台电脑可以同时联网吗
- =============SQL 查询语句===============
- 列转行 在线等 请高手们指点指点
- ===========这个语句怎么改?=================
- 请教一个sql语句或存储过程~先谢谢了
- Sql Server 2000数据丢失,因为突然断电,当开机后发现断电之前的数据都没有保存下来,能用什么方法恢复吗? 急!~急急急。
- 请教复杂的SQL Update语句。(在线等待﹐急﹐请帮忙﹗)
- Sql server2000表中的逻辑字段是不是“Bit”?
- 关于游标问题!!!(高分)
sum(case 类别名称 when '饮料' then 数量 else 0 end) as 饮料,
sum(case 类别名称 when '点心' then 数量 else 0 end) as 点心,
sum(case 类别名称 when '主食' then 数量 else 0 end) as 主食,
sum(数量) as 总计
from 表1,表2,表3
on 表1.id=表2.id and 表2.id =表3.id
group by 日期