• raghuldrag (8/28/2012)


    alter procedure Goals_history

    (

    @stuid nvarchar(22),

    @startyear nvarchar(22),

    @endyear nvarchar(22),

    )

    as

    begin

    select name,class,noofsubject,rank,test from @tab1

    union

    select name,class,subject,rank,test from @tab2

    where rank is not null

    and studentname=@stuid

    and accodomicyear>=@startyear

    and accodomicyear<=@endyear

    end

    OUTPUT:

    class noofsubject rank test name

    2 5 1 revision ravi

    2 5 - monthly raju

    2 5 3 midterm ravi

    6 4 - monthly somu

    2 5 - revision ravi

    expectin output:(rank is null means show first)

    class noofsubject rank test name

    6 4 - monthly somu

    2 5 - monthly raju

    2 5 - revision-II ravi

    2 5 1 revision ravi

    2 5 3 midterm ravi

    (if he have rank means the output comes on subdivision how to make the query)

    Hi raghuldrag,

    Please provide the DDL of tables with sample data.

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂