Background:
Why is it a shame before the snow? Think that year, I was small, I went out to interview the ocean, far from looking at Hao brother sitting there, and then go to dinner, I and Donghui is there quietly waiting for the second round of technical interview (the result is no face, one is academic issues), finally a small sister took me away, asked me a lot of questions, Like what WCF Ah, mvc ah what, did not ask, directly ask me, backstage how, will write SQL, I said of course, in the former main dry backstage, he asked at the same time made several problems, one of which is also the last I did not call up the problem such as:
Tell me how to write can output the effect:
Quiet meditation, rest for a while, think, and finally said: "Sorry, I am a little nervous, temporary solution", the people said, this is very simple ah, should how how, she also wrote a moment, said, certainly can achieve, I said: "Is."
I went out to work for a period of time, the use of SQL to solve a lot for, but also help colleagues to spell SQL, finally their level has a little progress, just now, suddenly I think of this period of past, decided to solve the problem of their own, Kung Fu is not a conscientious, completed, share:
Select Studentname, (select Result from TestTable as RT where Rt. Studentname=st. Studentname and RT. Lessonname= ' language ') as Chinese, (select Result from TestTable as BT where BT. Studentname=st. Studentname and BT. Lessonname= ' math ') as Suanshu (case when (select Result from TestTable as RT where Rt. Studentname=st. Studentname and RT. Lessonname= ' language ') >0 then (select Result from TestTable as BT where BT. Studentname=st. Studentname and BT. Lessonname= ' language ') ELSE 0 END + Case if (select Result from TestTable as RT where Rt. Studentname=st. Studentname and RT. Lessonname= ' math ') >0 then (select Result from TestTable as BT where BT. Studentname=st. Studentname and BT. Lessonname= ' math ') ELSE 0 END) as Resultsumfrom testtable as St GROUP by St. Studentname ORDER by Resultsum desc</span>
If there is a need to explain or better advice comrade, please contact QQ
A snow before Shame--sql interview article