Purchase Solution

Improvements to SQL queries for Student data

Not what you're looking for?

Ask Custom Question

I have tried there two queries, but I am told that I am not doing something right. Here are the criteria I used to write the queries and my current answers.
1. Write a SELECT statement that lists the StudentID, FirstName, LastName, and GPA of freshman (FR) whose GPA is 3.5 or higher. Use only the Student table.
My query:
SELECT StudentID, FirstName, LastName, GPA
FROM Students
WHERE Year like '%FR%' AND GPA >= 3.5

2. Write a SELECT statement that returns all the information for junior and senior students whose GPAs are lower than 3.0. Sort by LastName in descending order. Use only the Students table.
My query:
SELECT *
FROM Students
WHERE GPA < 3.0 and Year like '%JR%' OR '%SR%'
ORDER BY LastName DESC

How can I edit my queries so that they are completely correct. The SQLyog is returning the correct answers, but I keep getting marked incorrect.

Purchase this Solution

Solution Summary

The solution is a careful analysis to the queries as given for improvements.

Solution Preview

Student, since you say "SQLyog is returning the correct answers" I suspect we only need to tweak your queries a bit. To be sure, I would liked you to have attached your query output and the Students table schema. I think the problem you are getting in your marks is because you are using "Year like" when you should use an "=" comparison. "=" is a more SARGable search parameter than "LIKE", meaning SQL is optimized to returnig "=" results faster and more efficiently using ...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.