第1个回答 2014-09-24
create table card (
fundaccount int ,
bankno char(1),
cardno char(20)
)
insert into card
select 1,'1','111111111111'
union all
select 2,'2','111111111111'
union all
select 3,'2','222222222222222'
update card set cardno='100'+cardno from card
where bankno='2'
and len(LTRIM(RTRIM(cardno))) =12
select *,len(cardno) from card
---------------------
第二个懒的建表的,核心就是求出客户代码,然后在关联
select top 5 客户代码 from ( select
客户代码,姓名,SUM(XX) AS XX FROM XXX
where way=1 and year(date)=1998 and month(date)=3
GROUP BY
客户代码,姓名
)
order by 成交金额
第2个回答 推荐于2016-09-27
update card set cardno='100'+cardno where bankno='2' and len(cardno)=12
select top 5 cusinfo.cusid,cusinfo.name,sum(jyinfo.money),sum(jyinfo.sxf) from jyinfo left join cusinfo on jyinfo.cusid=cusinfo.cusid
where jyinfo.way=1 and datediff(month,jyinfo.date,‘1998-3-1’)=0
group by cusinfo.cusid,cusinfo.name
order by sum(jyinfo.money) desc
大概应该是这样子本回答被提问者采纳