易截截图软件、单文件、免安装、纯绿色、仅160KB

求一个sql 语句

  table1
  名称      入库数
  CT机        3   
  CT机        5
  X光机      4
  X光机      5


要求查询的结果如下。环境是sql server 2005

  名称      入库数
  CT机        3   
  CT机        5
  小计        8
  X光机      4
  X光机      5
  小计        9
SQL code:
select isnull(名称,'小计') as 名称,sum(入库数) as 入库数
from tb
group by 名称 with rollup


引用
SQL codeselectisnull(名称,'小计')as 名称,sum(入库数)as 入库数from tbgroupby 名称with rollup
up+蹭分

您这是在什么数据库做啊?

引用
SQL codeselectisnull(名称,'小计')as 名称,sum(入库数)as 入库数from tbgroupby 名称with rollup

SQL code:

DECLARE @TB TABLE([名称] NVARCHAR(3), [入库数] INT)
INSERT @TB
SELECT N'CT机', 3


相关问答:

pl/sql导入数据问题

我EXCEL中一个单元格的数据如  "2009-01","8949-232"

将这个数据粘贴到PL/SQL中的一个表中后,数据确是成为了 2009-01,8949-232 ,把所有的""都没了,
如何弄呢?请大家试 ......

总会碰到怪的问题,sql问题

sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and  xxfwzf <>0 ),执行速度慢的要死,但是如果把(xxf>0 and  ......

请教一个sql数据筛选问题

有字段
日期,id

日期不重复,id 有重复

需要筛选出 每个id里面日期最早的数据。
SQL code:
select * from 表 t where not exists(select 1 from 表 where t.日期>日期 and id=t.id)

SQL ......

oracle sql developer 查询显示中文乱码

环境:1.win2003server+oracle9i
2.oracle9i字符集为AMERICAN_AMERICA.WE8ISO8859P1
3.oracle sql developer版本 1.5.5
现象描述: 1.在sql developer 中查询oracle中的某个表,中文全部显示为乱码。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号