Interview questions: SQL data query

Source: Internet
Author: User

A few days ago to participate in an interview, interview company to do a set of questions, SQL problem is not difficult, but I was the first to write the wrong, come back, write the next. Simply record it,

1. Title:

2. Test data

SELECT * from student; INSERT into student (Name,subject,score) VALUES (' Zhang ', ' language ', "); INSERT into student (Name,subject, Score) VALUES (' Zhang ', ' math ', ' a '), insert into student (Name,subject,score) VALUES (' Zhang ', ' English '), insert into student (name, Subject,score) VALUES (' King ', ' language ', ' n '), insert into student (Name,subject,score) VALUES (' King ', ' English '), insert into student ( Name,subject,score) VALUES (' Li ', ' math '), insert into student (Name,subject,score) VALUES (' Zhao ', ' English ', 88);

Student table, altogether three fields name, subject, score (data types are varchar (), varchar (+), int), test table, relatively simple.

3. I wrote the SQL

Select M.name from (select S.name, S.score, Dense_rank () through (PARTITION by s.name ORDER by s.score ASC) as Score_rank from Student s) m where M.score_rank = 1 and M.score >=60;

If you have any objection, please correct me.

Interview questions: SQL data query

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.