You are here: Re: Problem with SELECT « MsSQL Server « IT news, forums, messages
Re: Problem with SELECT

Posted by Alexander Kuznetsov on 08/21/06 19:35

Ted wrote:
> I constructed the following SQL statement by studying the example on
> page 392 in Itzik Ben Gan et al.'s "Inside Microsoft SQL Server 2005:
> T-SQL Querying"
>
> SELECT s_supplier_code, s_supplier_name FROM suppliers AS S1
> WHERE s_supplier_code =
> (
> SELECT TOP(1) * FROM suppliers AS S2
> WHERE S2.s_supplier_code = S1.s_supplier_code
> ORDER BY s_supplier_name
> )
> ;
>

Ted,

The example in Listing 7-1 is different from your query, and the
example works (and it makes perfect sense to me). I am not sure I
understand what you were trying to accomplish. Note that:
1. Listing 7-1 uses SELECT TOP(1) OrderId, as opposed to your top(1) *
2. Listing 7-1 uses different columns to filter the result set
(OrderId) and to correlate the subquery (EmployeeId). Using one and the
same solumn s_supplier_code in both cases makes little sense to me.

Good luck!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация