Record the SQL interview questions you see online and fill out the answers yourself

Source: Internet
Author: User

Structure of the table
Student (s#,sname,sage,ssex) Student table
Course (c#,cname,t#) timetable
SC (s#,c#,score) score table
Teacher (t#,tname) Teacher table

    1. Creating the corresponding table CREATE table student (' s# ' int, sname varchar (+), Sage int, s Sex varchar) The following omit 2. Inserting data insert into student Select 1, ' Zhang San ', 18, ' Male ' union ALL select 2, ' John Doe ', 18, ' Male ' Unio    n all .... 3. Check the number of all students with "001" courses that are higher than the "002" course; Select a. ' s# ' from SC A,sc b where a. ' C # ' =001 and B. ' C # ' =002 and A.score>b.score ;! [] (http://i2.51cto.com/images/blog/201805/22/696290ad72878304ef70251fbdec2afb.png?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) 4. Search for students with average scores greater than 60 points and average scores; Select ' s# ', AVG (score) from SC Group BY ' s# ' have avg (score) >60! [] (http://i2.51cto.com/images/blog/201805/22/985a3a24041520bae9be634704eb611c.png?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) ! [] (Http://i2.51cto.com/images/blog/201805/22/985a3a24041520bae9be634704eb611c.png?x-oss-process=imAge/watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_ zmfuz3pozw5nagvpdgk=)

Record the SQL interview questions you see online and fill in your answers

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.