一行返回的列数据

时间:2019-06-03 06:17:22

标签: sql sql-server tsql

我正在使用以下查询:

    select i.name as 'index name',c.name as 'column' from sys.indexes i 
    join  sys.columns c  on i.object_id = c.object_id;

查询返回的数据如下:

    clst    bitpos
    clst    cid
    clst    colguid
    clust   cmprlevel
    clust   fgidfs
    clust   fillfact

但是,我想查看以下数据:

  clst  bitpos, cid,    colguid
  clust cmprlevel,  fgidfs  fillfact

我这样尝试过与众不同和分组。但这不起作用:

    select distinct(i.name) as 'index name',c.name as 'column' from s 
   ys.indexes i join  sys.columns c  on i.object_id = c.object_id group by i.name;

任何人都可以帮忙。我正在使用mssql

0 个答案:

没有答案