Friday, March 6, 2015

condtion based xml for each row of the table t-sql


select student_id,
case when min(Person.Name.value('./marks[1]','int')) <80 then 'demoted' else 'promoted' end as [marks]
from #students cross apply s_m_xml.nodes('/submarks/submark') as Person(Name)
group by student_id





Hope it Helps!!



No comments:

Post a Comment