Home Forums SQL Server 2008 T-SQL (SS2K8) How to display Columns based on other table values RE: How to display Columns based on other table values

  • hi lynn,

    i tried this way, am i doing correct , please correct me, is the case statement logic is good? or do i need to check some otherway

    please help me, it has to be run in optimized way,, so please suggest me i fi am doing anything wrong

    select

    sno,

    name,

    enroll,

    (Case when noMail.enroldate IS NULL then 'N' else 'Y' + CAST( noMail.enrollDate as varchar(20) ) end) as PTCol,

    (Case when Mail.enroldate IS NULL then 'N' else 'Y' + CAST( Mail.enrollDate as varchar(20) ) end) as DrillCol,

    from dbo.student t left join dbo.studentPT noMail on t.sno = noMail.sno

    left join dbo.studentDrill Mail on t.sno = Mail.sno