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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Embedded select statements..

Author  Topic 

lisleche
Starting Member

2 Posts

Posted - 2003-10-12 : 01:49:46
I am trying to do an embedded select statement in the where clause.. such as this..

select TITLE, COST
FROM movies
WHERE COST =(SELECT max(COST)
FROM movies)
ORDER BY TITLE


But I need to also do one for a variable of the cost with in $2.00 of the max cost.. How do I go about doing this.. every thing I have tried has failed.. I do not know where I am going wrong;

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-10-12 : 03:54:47
Try this:

SELECT TITLE, COST FROM movies
WHERE ((SELECT MAX(COST) FROM movies) - COST) <= 2

Owais




Make it idiot proof and someone will make a better idiot
Go to Top of Page

lisleche
Starting Member

2 Posts

Posted - 2003-10-12 : 04:10:58
Yes this works. Thanks.. I was making things really difficult for myself. I guess I just needed to simplify..
Go to Top of Page
   

- Advertisement -