Showing posts with label according. Show all posts
Showing posts with label according. Show all posts

Friday, March 23, 2012

ORDER BY columns in SELECT list?

According to BOL, columns in an ORDER BY clause do not have to be in the SELECT
column list unless the SELECT includes DISTINCT, or the UNION operator.

Is this a SQL Server thing, or SQL standard behavior? That is, if I were to write
absolutely pure SQL-92, must columns in the ORDER BY clause be present in the SELECT
list?SQL-92 demands the columns specified in the ORDER BY clause be present in
the SELECT list. I guess the recent standards (99, 03 etc) does not have
this requirement.

--
- Anith
( Please reply to newsgroups only )

Wednesday, March 21, 2012

ORDER BY

hi,

i' ve Drop Down List with sorted catagory and Data Grid that cange according to selected item in drop down list ... i need to send the selected item as value to SELECT statment, so i 've send (option) as a value

"SELECT [userstory].* FROM [userstory] WHERE ([userstory].[rel_id] = @.rel_id) ORDER BY @.options "

but there is an error:

The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name

You should order by a column name and not a param. Soif your field is payDate in your DB then you would do order by payDate .|||

thanks for answering

bt if i need to use variable as ordered by coz i've send for 1st time order by status 2nd order by risk .. an so on..

can i?