Home Forums SQL Server 2008 T-SQL (SS2K8) Retrives the subject wise highest marks list in a table RE: Retrives the subject wise highest marks list in a table

  • select tbl.id, st.studname,tbl.subject

    from Student st

    join

    (

    select id, 'maths' as subject from Marklist where maths= (select max(maths) from Marklist )

    union

    select id, 'physics' as subject from Marklist where physics = (select max(physics) from Marklist )

    union

    select id, 'English' as subject from Marklist where English = (select max(English) from Marklist )

    )

    tbl

    on st.id = tbl.id