请教SQL语句,很急,谢谢[求助]

ProDate ClassOrder Type RunTime ValuePH Rigidity
2002-11-28 0 -- 8 时 第一号给水 1 3 4
2002-11-28 0 -- 8 时 第二号给水 1 4 5

原chem数据查询结果,我想合并两条记录为一条,条件是prodate、classorder、runtime相等,结果如下显示,请教SQL语句怎样生成

ProDate ClassOrder RunTime Type ValuePH Rigidity Type1 ValuePH1 Rigidity1
2002-11-28 0 -- 8 时 1 第一号给水 3 4 第二号给水 4 5

如果是多条记录合并的话可以吗?我可以确定有哪些字段

---------------------------------------------------------------

做八个连接:
select A.ProDate,A.ClassOrder,A.RunTime,A.Type,A.ValuePH,A.Rigidity,
B.Type Type1, B.ValuePH ValuePH1, B.Rigidity Rigidity1
........
H.Type Type8, H.ValuePH ValuePH8, H.Rigidity Rigidity8
from tablename as A
full join tablename as B
on A.ProDate = B.ProDate
and A.ClassOrder = B.ClassOrder
and A.runtime = B.runtime
and A.Type = '第一号给水'
and B.Type = '第二号给水'
........
full join tablename as H
on A.ProDate = H.ProDate
and A.ClassOrder = H.ClassOrder
and A.runtime = H.runtime
and A.Type = '第一号给水'
and H.Type = '第八号给水'

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus