A snow before Shame--sql interview article

Source: Internet
Author: User



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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.