急寻高手帮帮忙 求一个sql查询导入excel(60分)

  • 主题发起人 主题发起人 meijingpengwork
  • 开始时间 开始时间
M

meijingpengwork

Unregistered / Unconfirmed
GUEST, unregistred user!
数据库中统计出来<br>SELECT a.NO,a.d_date, b.name,b.num,b.weight FROM Tablea a LEFT JOIN Tableb b<br>&nbsp;ON a.NO= b.NO<br>NO &nbsp; &nbsp; &nbsp; &nbsp;DATE &nbsp; &nbsp; &nbsp; &nbsp; name &nbsp; &nbsp; num &nbsp; &nbsp; &nbsp; weight <br>1 2008-02-02 黄金 1.0 8.8 &nbsp; &nbsp; <br>2 2007-01-01 水晶 2.0 9.9 &nbsp; &nbsp; <br>3 2008-11-11 钻石 3.0 9.8 &nbsp; &nbsp; <br>如何统计出 按name分类的 &nbsp;excel导入的格式<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 黄金 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;水晶 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 钻石<br>NO &nbsp; &nbsp;DATE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NUM &nbsp;WEIGHT &nbsp; &nbsp; NUM &nbsp;WEIGHT &nbsp; &nbsp; NUM &nbsp;WEIGHT &nbsp; &nbsp; <br>1 &nbsp; &nbsp; 2008-02-02 &nbsp; &nbsp;2.0 &nbsp; 16 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>2 &nbsp; &nbsp; 2007-01-01 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.0 &nbsp; 9.9<br>3 &nbsp; &nbsp; 2008-11-11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3.0 &nbsp; 9.8
 
行转列的问题,可以参考如下:<br>create procedure HangZhuanLie as<br>declare @sql varchar(8000)<br>--create table zzz(xm varchar(10),km varchar(20),score int)<br>set @sql='select xm 姓名'<br>select @sql=@sql+',isnull(sum(case km when '''+km+''' then score end),0) '''+km+'''' from (select distinct(km) km from zzz) aaa<br>select @sql=@sql+' from zzz group by xm'<br>print @sql<br>exec(@sql)
 
我参考出来了,谢谢你的帮忙。祝愉快。送分了
 
后退
顶部