select a.nsrsbh as 纳税人识别号,nvl(b.纳税人名称,nvl(c.nsrmc,'')) as 纳税人名称,a.se as 税额 from sb_zsxx as a
left join dj_nsrxx as b on a.nsrsbh=b.纳税人识别号
left join sb_lszsnsrxx as c on a.nsrsbh=c.nsrsbh
#2
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.[纳税人名称],C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.[纳税人识别号]
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
ORACLE?我还去查了下ORACLE的ISNULL~~
需不需要聚合呢?
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.[纳税人名称],C.nsrmc)[纳税人名称]
,SUM(A.se[税额])[总税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.[纳税人识别号]
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
GROUP BY
A.nsrsbh
,NVL(B.[纳税人名称],C.nsrmc)
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
聚合
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,SUM(A.se)[总税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
GROUP BY
A.nsrsbh
,NVL(B.nsrmc,C.nsrmc)
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=C.nsrsbh
我错了一个字符~~
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=
B.nsrsbh
改为C~~
#11
SELECT
A.nsrsbh
,B.nsrmc,
,A.se
FROM
sb_zsxx A,dj_nsrxx B
WHERE A.nsrsbh=B.nsrsbh
上面的语句可以正常执行,但是下面的语句无法执行:
SELECT
A.nsrsbh
,B.nsrmc,
,A.se
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
是不是ORACLE数据库不适用JOHN语法啊
WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh
那你先这样连接吧~
再找下原因~
9i已经直接JOIN了
也可以再试试
LEFT JOIN换成
LEFT OUTER JOIN
#17
谢谢,我试试
#18
郁闷,不成功。WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh 应该是交集,更不可行,and换成or,往往语句半天没反应。left join换成left outer join同样不执行。
#19
WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh 应该是交集
这点是我漏了~~
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE(A.nsrsbh=B.nsrsbh(+) OR A.nsrsbh=C.nsrsbh(+)) AND 其他条件
试下这个
#20
好的,谢谢,明天上班试试!
#21
#22
ORACLE这么奇怪?
那你再试下
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE A.nsrsbh=B.nsrsbh(+) AND A.nsrsbh=C.nsrsbh(+) AND 其他条件
select a.nsrsbh as 纳税人识别号,nvl(b.纳税人名称,nvl(c.nsrmc,'')) as 纳税人名称,a.se as 税额 from sb_zsxx as a
left join dj_nsrxx as b on a.nsrsbh=b.纳税人识别号
left join sb_lszsnsrxx as c on a.nsrsbh=c.nsrsbh
#2
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.[纳税人名称],C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.[纳税人识别号]
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
ORACLE?我还去查了下ORACLE的ISNULL~~
需不需要聚合呢?
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.[纳税人名称],C.nsrmc)[纳税人名称]
,SUM(A.se[税额])[总税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.[纳税人识别号]
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
GROUP BY
A.nsrsbh
,NVL(B.[纳税人名称],C.nsrmc)
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
聚合
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,SUM(A.se)[总税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=B.nsrsbh
GROUP BY
A.nsrsbh
,NVL(B.nsrmc,C.nsrmc)
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=C.nsrsbh
我错了一个字符~~
LEFT JOIN sb_lszsnsrxx C ON A.nsrsbh=
B.nsrsbh
改为C~~
#11
SELECT
A.nsrsbh
,B.nsrmc,
,A.se
FROM
sb_zsxx A,dj_nsrxx B
WHERE A.nsrsbh=B.nsrsbh
上面的语句可以正常执行,但是下面的语句无法执行:
SELECT
A.nsrsbh
,B.nsrmc,
,A.se
FROM
sb_zsxx A
LEFT JOIN dj_nsrxx B ON A.nsrsbh=B.nsrsbh
是不是ORACLE数据库不适用JOHN语法啊
WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh
那你先这样连接吧~
再找下原因~
9i已经直接JOIN了
也可以再试试
LEFT JOIN换成
LEFT OUTER JOIN
#17
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh
那你先这样连接吧~
再找下原因~
9i已经直接JOIN了
也可以再试试
LEFT JOIN换成
LEFT OUTER JOIN
谢谢,我试试
#18
郁闷,不成功。WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh 应该是交集,更不可行,and换成or,往往语句半天没反应。left join换成left outer join同样不执行。
#19
WHERE A.nsrsbh=B.nsrsbh AND A.nsrsbh=C.nsrsbh 应该是交集
这点是我漏了~~
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE(A.nsrsbh=B.nsrsbh(+) OR A.nsrsbh=C.nsrsbh(+)) AND 其他条件
试下这个
#20
好的,谢谢,明天上班试试!
#21
#22
ORACLE这么奇怪?
那你再试下
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE A.nsrsbh=B.nsrsbh(+) AND A.nsrsbh=C.nsrsbh(+) AND 其他条件
虽然不符逻辑,不过说不定可行
#23
ORACLE这么奇怪?
那你再试下
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE A.nsrsbh=B.nsrsbh(+) AND A.nsrsbh=C.nsrsbh(+) AND 其他条件
SELECT
A.nsrsbh[纳税人识别号]
,NVL(B.nsrmc,C.nsrmc)[纳税人名称]
,A.se[税额]
FROM
sb_zsxx A,dj_nsrxx B,sb_lszsnsrxx C
WHERE A.nsrsbh=B.nsrsbh(+) AND A.nsrsbh=C.nsrsbh(+) AND 其他条件