有没有大神可以简化这样的sql
sqlserver吧
全部回复
仅看楼主
level 1
select 'SS' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from
(
select 11,22 from A
where as = '44' and qw = 1
) as a
full join
(select 11,22 from A
where as = '55' and qw =1
) as b
on isnull(a.11, '') = isnull(b.11, '')
where lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
union
select 'QQ' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from
(
select 11,22 from B
where as = '44' and qw = 1
) as a
full join
(select 11,22 from B
where as = '55' and qw =1
) as b
on isnull(a.11, '') = isnull(b.11, '')
where lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
2017年01月17日 05点01分 1
level 1
select 'SS' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from
(
select 11,22 from AA
where aa = '44' and qw = 1
) as a
full join
(select 11,22 from AA
where aa = '55' and qw =1
) as b
on isnull(a.11, '') = isnull(b.11, '')
where lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
union
select 'QQ' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from
(
select 11,22 from BB
where aa = '44' and qw = 1
) as a
full join
(select 11,22 from BB
where aa = '55' and qw =1
) as b
on isnull(a.11, '') = isnull(b.11, '')
where lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
================================================================
select 'SS' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from Aa a
full join AA b
on isnull(a.11, '') = isnull(b.11, '')
where
aa = '44'
and qw = 1
and aa = '55'
and qw =1
and lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
union
select 'QQ' as [Group]
, isnull(a.11,b.11) as description
, lower(isnull(a.11,'')) as value1
, lower(isnull(b.11,'')) as value2
from BB a
full join BB b
on isnull(a.11, '') = isnull(b.11, '')
where
aa = '44'
and qw = 1
and aa = '55'
and qw =1
and lower(isnull(a.22,'qaz')) != lower(isnull(b.22,'qaz'))
2017年01月17日 05点01分 2
level 1
为什么 我 优化 出来 查出来的数据 一样,哪里错了 有没有大神啊
2017年01月17日 05点01分 3
level 1
来不short=nvjU8xb
2017年02月02日 00点02分 6
1