列应该转换为行

时间:2015-11-13 09:40:45

标签: sql sql-server sql-server-2008 sql-server-2008-r2 sql-server-2012

包含数据

的下表
 CREATE TABLE [dbo].[T_shirt_sizes](
   [Id] [int] IDENTITY(1,1) NOT NULL primary key,
   [Code] [varchar](100) NULL,
   [Length] [varchar](100) NULL,
   [Chest] [varchar](100) NULL,
   [Shoulder] [varchar](100) NULL,
   [Sleeve Length] [varchar](100) NULL
  )
insert into T_shirt_sizes values('XXS','20’','29”','13 1/4”','6”')
insert into T_shirt_sizes values('XS','21 3/4”','31"','14 1/2”','6 1/8”')
insert into T_shirt_sizes values('S','23 3/4”','33"','16 1/4”','6 1/4')
insert into T_shirt_sizes values('M','25 3/4”','36"','17','7”')
insert into T_shirt_sizes values('L','27 3/4”','39"','17 1/2”','7 1/2')

我希望得到像这样的输出

 T-shirts   | XXXS    | XXS    | XS     |   S       |  M    | L
 -----------------------------------------------------
 Length      18 3/4”  | 20’    |21 3/4” | 23 3/4”   |25 3/4”|   27 3/4”
 Chest          27”   | 29”    |31”     |  33”      |  36”  |    39”
 Shoulder     12 1/2” | 13 1/4”| 14 1/2”| 16 1/4”   |17”    |  17 1/2”
 Sleeve Length  5 1/2”| 6”     | 6 1/8” |  6 1/4    |7”     |  7 1/2

请帮助解决上述问题

1 个答案:

答案 0 :(得分:2)

您需要再次- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; { static NSString *cellIdentifier = @"CellID"; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (!cell) { // if cell is empty create the cell cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; } cell.ProfilehdLabel.text = [profilehd objectAtIndex:indexPath.row]; cell.profileImgvw.image = [UIImage imageNamed:[profileimg objectAtIndex:indexPath.row]]; return cell; } UNPIVOT

PIVOT

LiveDemo