如何为它编写sql语句?

时间:2012-07-25 03:57:07

标签: sql-server-2008

  

可能重复:
  how to write the sql statement?

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  

最重要的是,我想让'面试官'的名字取决于主要面试官的身份证。

1 个答案:

答案 0 :(得分:0)

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