111,129
社区成员
发帖
与我相关
我的任务
分享
-- 上面的表为table1,下面的表为table2
select top 1 t2.idcardnumber,t2.name,t2.mobile,t1.csp from table2 t2 left join (select id,csp = sum(csp) from table1 group by id) t1 on t2.id = t1.id order by t1.csp desc

select top 1 * from (select id, sum(csp) as csp from table1 group by id)表1 join 表2 on 表1.id=表2.id order by 表1.csp desc
-- 上面的表为table1,下面的表为table2
select t2.idcardnumber,t2.name,t2.mobile,t1.csp from table2 t2 left join (select id,csp = max(csp) from table1 group by id) t1 on t2.id = t1.id
select t1.id, t1.csp, t2.卡号, t2.姓名, t2.电话
from (select id, max(csp) as csp from table1 group by id) t1 left join table2 t2 on t2.id = t1.id

[/quote]
你把想要结果集大致写下
[/quote]
你把想要结果集大致写下[/quote]
id ,name,moblie,csp(csp是max),最好分别求出一列一列的,因为要把值传到textbox里面
