How to create student mark sheet like Turm in SQL Server -


I want to show a student mark sheet like this:

  ----- -------------------------------------------------- - First tour. Second Touram | -------------------------------------------------- ------- S_ID | SUB_NAME | Outf. Points | Outf. Mark ------------------------------------------------- -------- 101 English 100 90 100 90 101 History 100 80 100 80 101 Mathematics 140 80 140 80 101 Sanskrit 100 75 100 75 102 English 100 80 100 80 102 History 100 80 100 80 102 Mathematics 140 80 140 80 102 Sanskrit 100 80 100 80   

I use the pivot keyword for this I get this output

  table #t (S_ID integer, create SUB_NAME varchar ( 10), integer, mark integer, term integer) in the #t (S_ID, SUB_NAME, term, outof, marks) value (101, & amp; # 39; Mathematics & amp; # 39 ;, 1,140,80 ) Insert in #t (S_ID, SUB_NA ME, Terms, Outof, Marks) VALUES (101, & amp; # 39; English & amp; # 39; 1,100,90) #t (S_ID, SUB_NAME, Term, Outof, Marks) Value (101, & # 39; SANSKRIT & amp; # 39; 1,100,75) Enter #t (S_ID, SUB_NAME, Term, Oundof, Marks) in Value (101, & # 39; History & # 39; 1,100,80) in #t ( S_ID, SUB_NAME, Trm, Autof, Marx) value (102, & amp; # 39; MATHS & amp; # 39;, 1,140,80) #t (S_ID, SUB_NAME, terms, Aundof, Marx) value (102 & Amp; ; # 39; In English & amp; # 39 ;, 1,140,80) #t (S_ID, SUB_NAME, terms, outof, marks) Enter values ​​(102, & S; SANSKRIT & amp; # 39 ;, 1,140,80) #t (S_ID, SUB_NAME, terms, Autof, insert Marks) vALUES (102, & amp; # 39; history & amp; # 39; 1,140,80) #t (S_aidi, SUB_NAME, terms, Autof, Marx) value (101 & amp; # 39; Maacs & amp; # 39; 2,140, ​​80) #t (S_ID, SUB_NAME, terms, Autof, Marx) value (# 101) into # t (S_aidi, Subeediaiad, Trm, Aundof, Marx) Insert in) Price (101, & S; SANSKRIT & amp; # 39; 2,100,75) #t (S_ID, SUB_NAME, Term) Value, outs, marks) value (101, & amp; # 39; history & amp; # 39; 2,100,80) #t (S_ID, SUB_NAME, terms, outof, marks) value (102, & amp; # 39; MATHS & amp; # 39; 2,140,80) insert into #t (S_ID, SUB_NAME, turm, Outoff), symbol) value (102, & amp; # 39; English & amp; # 39; 2,140,80) # T (S_aidi, SUB_NAME, terms, Autof, Marx) value (102, & amp; # 39; SANSKRIT & amp; # 39;, 2,140,80) #t (S_ID, SUB_NAME, terms, Autof, Marx) value ( 102, & amp; # 39; History & amp; # 39; 2,140,80) * Choose from (SELECT S_ID, SUB_NAME, CASE) when Tar Me = 1 THEN & amp; # 39; First Truman & amp; # 39; First & amp; Nbsp; Second touram & amp; # 39; As the end term, in the form of #t) from Marks (the first term), [second term]) for the Axis (Max (Marks) [term]) s drop table #t   

Output:

  S_ID | SUB_NAME | Outf. First Tour | Second Touram ------------------------------------------- ----- - 101 English 100 90 90 101 History 100 80 80 101 Mathematics 140 80 80 101 Sanskrit 100 75 75 102 English 140 80 80 102 History 140 80 80 102 Mathematics 140 80 80 102 Sanskrit 140 80 80    

This can also be solved like this:

  select S_ID, SUB_NAME, As the outcome, Max (the case when the term = 1 is the indicator of some other termination) as S_ID is the 'first term' from T group, max (case when the term = 2 is again an indicator of some and end) 'Second round In ', SUB_NAME, Autf    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -