2012-07-25 73 views
0

可能重複:
how to write the sql statement?如何爲它寫入sql語句?

IncidentReportid     Interviewers     MainInterviewer 
18 :Name/nric/Desg/iunit/remark: NAME2/inric/iDesg/iunit/iremark:    nric 
19 :irank/inric/iDesg/iunit/iremark:irank1/inric1/iDesg1/iunit1/iremark1:  inric 
20 :irank4/inric4/iDesg4/iunit4/iremark4:irank5/inric5/iDesg5/iunit5/iremark5: inric5 
21 :irank7/inric7/iDesg7/iunit7/iremark7:irank8/inric8/iDesg8/iunit8/iremark8: inric7 
23 :irank9/inric9/iDesg9/iunit9/iremark9:irank6/inric6/iDesg6/iunit6/iremark6: inric9 
24 :RankOfAddison/aNRIC/aInstructor/aUnit/aRemark:RankOfNang/nNRIC/nInstructor/nUnit/nRemark: aNRIC 

EG。我有上面的表格,我想獲得如下數據。謝謝。 :)

IncidentReportid    Interviewers  MainInterviewer    
18        Name    nric 
19        irank   inric     
20        irank5   inric5    
21        irank7   inric7     
23        irank9   inric9     
24        RankOfAddison aNRIC 

最主要的是,我想要得到的「面試」的名字依賴於主面試官的身份證。

+0

請更好地格式化您的示例數據。 – 2012-07-25 03:59:39

回答

0
select IncidentReportid, 
     SUBSTRING(Interviewers,2,CHARINDEX('/',Interviewers)-2) as Interviewers, 
     MainInterviewer 
from Table