活跃下气氛,9*9乘法表中的一个有关问题

活跃下气氛,9*9乘法表中的一个问题http://topic.csdn.net/u/20120525/16/1e09cbf2-2945-4d9e-ada7-1b03c12

活跃下气氛,9*9乘法表中的一个问题
http://topic.csdn.net/u/20120525/16/1e09cbf2-2945-4d9e-ada7-1b03c127051a.html?67353
根据9*9乘法表中的一个问题

假设一个表t(row,col,val)数据如下,刚好每行,每列存放的是9*9乘法口诀中的一个值,如何用一句话将其按9*9乘法表中数据的对应方式打印或选出来?
row col val
111x1=1
211x2=2
311x3=3
411x4=4
511x5=5
611x6=6
711x7=7
811x8=8
911x9=9
222x2=4
322x3=6
422x4=8
522x5=10
622x6=12
722x7=14
822x8=16
922x9=18
333x3=9
433x4=12
533x5=15
633x6=18
733x7=21
833x8=24
933x9=27
444x4=16
544x5=20
644x6=24
744x7=28
844x8=32
944x9=36
555x5=25
655x6=30
755x7=35
855x8=40
955x9=45
666x6=36
766x7=42
866x8=48
966x9=54
777x7=49
877x8=56
977x9=63
888x8=64
988x9=72
999x9=81

[解决办法]

SQL code
declare @x intdeclare @y intdeclare @c varchar(6000)set @x = 1while(@x<=9)begin select @y=@x,@c='' while(@y<=9) begin   select @c=cast(@x as varchar)+'x'+cast(@y as varchar)+'='        +(case when len(ltrim(@x*@y))>1 then '' else ' ' end)+ltrim(@x*@y)+' '   select @y=@y+1   print @c end select @x=@x+1end/****************1x1= 1 1x2= 2 1x3= 3 1x4= 4 1x5= 5 1x6= 6 1x7= 7 1x8= 8 1x9= 9 2x2= 4 2x3= 6 2x4= 8 2x5=10 2x6=12 2x7=14 2x8=16 2x9=18 3x3= 9 3x4=12 3x5=15 3x6=18 3x7=21 3x8=24 3x9=27 4x4=16 4x5=20 4x6=24 4x7=28 4x8=32 4x9=36 5x5=25 5x6=30 5x7=35 5x8=40 5x9=45 6x6=36 6x7=42 6x8=48 6x9=54 7x7=49 7x8=56 7x9=63 8x8=64 8x9=72 9x9=81
[解决办法]
标准的行转列
[解决办法]
探讨

用case when +group by 进行行转列。