table money FEntryDC 500 0 1000 0 2000 1 3000 1select a.money as 借,b.money as 贷 from table a,table b where a.money=b.money and a.FEntryDC=0 and b.FEntryDC=1表的子连接
select id, 借=(select case FEntryDC[借/贷] when 0 then [借/贷] else null end from tableA where id=a.id), 贷=(select case FEntryDC[借/贷] when 1 then [借/贷] else null end from tableA where id=a.id) from tableA a
sorry,FEntryDC[借/贷] 换成 FEntryDC
select (case when FEntryDC=0 then 借 else "") 别名1, (case when FEntryDC=1 then 贷 else "") 别名2 FROM TABLE
create table # ( FEntryDC int, FMoney int ) insert into # select 1,1200 union select 1,2400 union select 0,1000select (case when FEntryDC=0 then FMoney else '' end) as '借', (case when FEntryDC=1 then FMoney else '' end) as '货' FROM #
money FEntryDC
500 0
1000 0
2000 1
3000 1select a.money as 借,b.money as 贷
from
table a,table b
where
a.money=b.money and a.FEntryDC=0 and b.FEntryDC=1表的子连接
select id,
借=(select case FEntryDC[借/贷] when 0 then [借/贷]
else null
end
from tableA where id=a.id),
贷=(select case FEntryDC[借/贷] when 1 then [借/贷]
else null
end
from tableA where id=a.id)
from tableA a
(case when FEntryDC=1 then 贷 else "") 别名2
FROM TABLE
(
FEntryDC int,
FMoney int
)
insert into # select 1,1200
union
select 1,2400
union
select 0,1000select (case when FEntryDC=0 then FMoney else '' end) as '借',
(case when FEntryDC=1 then FMoney else '' end) as '货'
FROM #