H
HON
Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何对TQUERY查询的结果集进行修改,加工等操作.
1.数据库CDKZ结构如下MS SERVER200)
CDH RQ JS ZL IO
000001 2002-5-1 100 1500 I
000002 2002-5-2 50 750 O
000003 2002-5-2 100 1500 I
000004 2002-5-2 50 750 0
TQUERY1的SQLSTRING如下:
SELECT CDH,RQ,(SELECT JS FROM CDKZ A1 WHERE A1.IO='I' AND A1.IO=A.IO AND A1.CDH=A.CDH) AS JC_JS,(SELECT ZL FROM CDKZ A1 WHERE A1.IO='I' AND A1.IO=A.IO AND A1.CDH=A.CDH)AS JC_ZL,(SELECT JS FROM CDKZ A1 WHERE IO='O' AND A1.IO=A.IO AND A1.CDH=A.CDH)AS CC_JS,
(SELECT ZL FROM CDKZ A1 WHERE A1.IO='O' AND A1.IO=A.IO AND A1.CDH=A.CDH) AS CC_ZL FROM CDKZ A ORDER BY RQ,CDH,IO
结果为:
CDH RQ JC_JS JC_ZL CC_JS CC_ZL
000001 2002-5-1 100 1500
000003 2002-5-2 100 1500
000002 2002-5-2 50 750
000004 2002-5-3 50 750
问: 如何增加一行,获得JC_JS,JC_ZL,CC_JS,CC_ZL 的合计数?能不用临时表实现吗?
1.数据库CDKZ结构如下MS SERVER200)
CDH RQ JS ZL IO
000001 2002-5-1 100 1500 I
000002 2002-5-2 50 750 O
000003 2002-5-2 100 1500 I
000004 2002-5-2 50 750 0
TQUERY1的SQLSTRING如下:
SELECT CDH,RQ,(SELECT JS FROM CDKZ A1 WHERE A1.IO='I' AND A1.IO=A.IO AND A1.CDH=A.CDH) AS JC_JS,(SELECT ZL FROM CDKZ A1 WHERE A1.IO='I' AND A1.IO=A.IO AND A1.CDH=A.CDH)AS JC_ZL,(SELECT JS FROM CDKZ A1 WHERE IO='O' AND A1.IO=A.IO AND A1.CDH=A.CDH)AS CC_JS,
(SELECT ZL FROM CDKZ A1 WHERE A1.IO='O' AND A1.IO=A.IO AND A1.CDH=A.CDH) AS CC_ZL FROM CDKZ A ORDER BY RQ,CDH,IO
结果为:
CDH RQ JC_JS JC_ZL CC_JS CC_ZL
000001 2002-5-1 100 1500
000003 2002-5-2 100 1500
000002 2002-5-2 50 750
000004 2002-5-3 50 750
问: 如何增加一行,获得JC_JS,JC_ZL,CC_JS,CC_ZL 的合计数?能不用临时表实现吗?