我有这样的输出:
foldername setname testname step stepdescription
------------------------------------------------------------------------------
name1.0 setname 1.1.1 testname1 step1 stpdes5
name2.1 setname 1.0.0 testname2 step1 asdf5
name2.1 setname 1.0.0 testname2 step2 ;lkj10
name2.1 setname 1.0.0 testname2 step3 aaaaaa10
name3 setname 1.2.1 testname3 step1 nnnn10
我想以下面的方式输出:
foldername setname testname step stepdescription
----------------------------------------------------------------------------
name1.0 setname 1.1.1 testname1 step1 stpdes5
name2.1 setname 1.0.0 testname2 step1 asdf5
step2 lkj10
step3 aaaaaa10
name3 setname 1.2.1 testname3 step1 nnnn10
答案 0 :(得分:1)
您可以使用ROW_NUMBER
执行此操作SELECT case when seq >1 THEN '' ELSE foldername END as foldername,
case when seq >1 THEN '' ELSE setname END as setname,
case when seq >1 THEN '' ELSE testname END as testname,
step,
stepdescription
FROM
(
SELECT *,
ROW_NUMBER() OVER ( PARTITION BY foldername, setname, testname order by (select NULL) ) as seq
FROM Table1
) T