我有这样如何使用数据透视
Name VALUE
ClientID M01010001250
InterviewType 1
InterviewDate 7/8/2011
ClientID M01010001260
InterviewType 1
InterviewDate 7/8/2011
ClientID M01010001260
InterviewType 5
InterviewDate 1869-07-01
ClientID M01010001290
InterviewType 1
InterviewDate 7/8/2011
的日期现在我出来放应该是这样的
SEQ ClientID InterviewType InterviewDate
1 M01100016550 5 9/9/2011
2 M01100016550 5 9/9/2011
3 M01030000680 5 9/9/2011
我已经写了使用数据透视查询,使行入列:
SELECT SEQ,ClientID,InterviewType,InterviewDate
FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY NAME,VALUE ORDER BY NAME,VALUE) AS SEQ,NAME,VALUE
FROM Table1) DT
PIVOT (MAX(VALUE)FOR NAME IN(ClientID,InterviewType,InterviewDate))DT1
ORDER BY SEQ
即使我使用row_number它没有给出所需的输出建议我
这已经被问27分钟前,我们给出了与9秒差异....的答案! :)你第一次,虽然... –