Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is this command correct

Author  Topic 

rhysE_b
Starting Member

4 Posts

Posted - 2009-11-06 : 11:09:31
Hey Guys,

If i was looking to sort everyone by the age of 25 or over would th command be this?

WHERE Age >= '25'

Thanks
Rhys

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-06 : 11:12:52
For sorting, you must use ORDER BY.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

rhysE_b
Starting Member

4 Posts

Posted - 2009-11-06 : 11:18:04
i have a test question that i have no idea what the answer is the question is.

"Please write an SQL query to display the first name, surname, and sex of all the technicians who are 25 and over"

and then under the question i have a table that looks something like this -

First Name | Surname | Age | Sex | Position

With 28 names and so on..


So far i have got....

select
[First Name], Surname, Sex
from Employees
where age >= '25'
and Position = 'technician'
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-11-06 : 11:42:30
are you getting correct results when you run the query? if age is numeric you dont need quotes around 25
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-11-06 : 11:43:28
That looks about right. The age field is probably a number field, so use
where age >= 25, without the quotes.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-06 : 11:44:33
Ah the test question doesn't mention sorting, so you don't need the ORDER BY.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -