用到如下语句:
select A,B,C from tableName where
TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '600' and A = (select max(A) from tableName where B = '600')
or TO_CHAR(A,'yyyy-MM-dd') like '2009-11-09' and B = '603' and A = (select ......
我有两个表,A表和B表,都只有一个字段,内容如下:
A表
号
1
1
2
B表
号
2
2
3
现在我想从这两个表中得到结果
号 号统计
1 2
2 3
3 1
SQL code:
SELECT ID,COUNT(1) from (
SELECT COL1 AS 'ID' from A
UNION ALL
SELECT C ......
序号 物料 数量 重量
1 A 3 5
1 A 5 6
1 B 2 6
2 C 1 9
2 D 4 2
2 D 6 3
2 C 8 5
我想得到的结果是:
序号 物料 数量 重量
1 A 8 11
1 B 2 6
合计 10 17
......
有两个表,一主一子。
主表order:
orderid ordertype
1 A
2 B
子表(order_car):
orderid carno
1 10
1 20
......
表A
字段 单号 物品名称
001 汽车
001 火车
001 飞机
002 汽车
002 &nb ......
如题,写了如下一段sql语句
insert T_jitong6(jixing,chehao,ReportTime,Peishu,ComeinTime,[State],Hidden)
select 车型,车号, 日期, 所属车间,入库时间,'合格','无'
from 机统6
where not exits
(select 1 from T_jitong6 where ReportTime =机统6.日期
and jixin ......