select *
商品 = a.name,
结存 = sum(c.goodnum)
from
goodtype a,
商品表 b,
(select goodsid,goodnum from HisStore
union all
select goodsid,goodsnum from InD) c
where
a.id = b.goodtype_id and b.id = c.goodsid
group by
a.name
商品 = a.name,
结存 = sum(c.goodnum)
from
goodtype a,
商品表 b,
(select goodsid,goodnum from HisStore
union all
select goodsid,goodsnum from InD) c
where
a.id = b.goodtype_id and b.id = c.goodsid
group by
a.name
解决方案 »
- Winfrom远程连接SQL Server问题
- 奇怪的sql server2005连接服务器问题
- 变量赋值问题
- 数据排序问题
- 请问如何把Access数据库转入到SQL Express 2005中?
- SQL2000 连接怪问题
- 谁给我点积分啊,我下东西老是提示积分不够?谢谢了!!!
- 请教sql如何写?字段名(月份,零售户代码,购进量)想查询出购进月份数不小于10个且购进总次数大于15的数据 内附测试数据 谢谢
- DBMS_SQL转换
- SQL Server 2000 产品上说的 10User 或者 25User 那是什么意思啊?
- 修改一个服务器上所有自建数据库中所有用户表的名字,所有列的名字,所有视图的名字,所有存储过程的名字,所有函数的名字.
- 写一个trigger,当每插入一列时,可以同时将插入条数(int)存入该表
商品 = a.name,
结存 = sum(c.goodnum)
from
goodtype a,
商品表 b,
(select goodsid,goodnum from HisStore
union all
select goodsid,goodsnum from InD) c
where
a.id = b.goodtype_id and b.id = c.goodsid
group by
a.name
2,查出所有期初有但后来入没有的种类T2.
3,查出所有期初无但后来有的种类T3.这样当然结余的种类数为:T1+T2+T3
Table1
T
1
2
3Table2
T
3
4
5select T1 from
(select A.T as T1,B.T as T2 from table1 A full join table2 B on A.T=B.T) A where T1 is not null and T2 is not null
union
select T1 as T2 from
(select A.T as T1,B.T as T2 from table1 A full join table2 B on A.T=B.T) A where T1 is not null and T2 is null
union
select T2 as T3 from
(select A.T as T1,B.T as T2 from table1 A full join table2 B on A.T=B.T) A where T1 is null and T2 is not null
我用这样的查询查出了所有可能的值.
大侠们帮看一下,我这种方法好不好?你们有什么好的方法没有?
用compute count(goodsid)不就解决了吗?
请举个例子,我看了一下帮助,没有看明白.