mardi 15 décembre 2015

do i need to add any more conditions?

I am trying to write condition for below condition, can any one help me ?

condition : For each unique combination of TZT.STU_ID and TZT.SPCL_CD where TZT.COLL_CD = '' , display the TZT.TERM_CD with the minimum TZT.TERM_SEQ_NUM For UID 202716354, based on the above rule, the value of this column is incorrect for both Specialization Codes.

SELECT [STU_ID]
      ,[TERM_CD]
      ,[SPCL_CD]
      ,[SPCL_STRT_TERM]
      ,(Select TERM_CD From SR0TZT(nolock) zt Inner Join (
  Select STU_ID,MIN(TERM_SEQ_NUM) MinPoint From SR0TZT Group By STU_ID) tbl1
                                                            On zt.STU_ID= tbl1.STU_ID
                                                            Where tbl1.MinPoint=zt.TERM_SEQ_NUM
                                                            and zt.STU_ID = @studentid and zt.COLL_CD = '') 'STU_SPCL_PROG_STRT_TERM'
from SR0TZT
where STU_ID = @studentid

order by TERM_SEQ_NUM asc`

Aucun commentaire:

Enregistrer un commentaire