Re: Sorting Problem
Posted in 2006
Topics: General Discussion
Based on your suggestions, I tried this and it works:
select id from table order by id[2, 6] + 0 desc
The infront character can be preserved as well.
Thanks again.
However, i got error while issue this query:
select distinct id from table order by id[2, 6] + 0 desc
SQL Error (-19828)
-19828 ORDER BY column or expression must be in SELECT list in this
context.
The ORDER BY column or expression can not be omitted from the SELECT
list in
the following situations:
* The UNIQUE or DISTINCT operator is used.
* The UNION operator is used.
* The query selects into a temporary table (SELECT ... INTO TEMP).
* In distributed queries that reference servers which always require
ORDER
BY columns to be in the SELECT list.
* Aggregate expressions are only allowed when the query uses the
GROUP BY
clause.
* The expression uses an alias to a column substring.
Revise the SQL statement to follow these rules.
I wish to select distinct data only.
Please help me, thanks.
select id, id[1,1], id[2,6] + 0 from table group by 1, 2, 3 order by 2
desc, 3 desc
Henry wrote:
> However, i got error while issue this query:
>
> select distinct id from table order by id[2, 6] + 0 desc>
> SQL Error (-19828)
>
> -19828 ORDER BY column or expression must be in SELECT list in this
> context.
>
>
> The ORDER BY column or expression can not be omitted from the SELECT
> list in
> the following situations:
>
>
>
> * The UNIQUE or DISTINCT operator is used.
>
> * The UNION operator is used.
>
> * The query selects into a temporary table (SELECT ... INTO TEMP).
>
> * In distributed queries that reference servers which always require
> ORDER
> BY columns to be in the SELECT list.
>
> * Aggregate expressions are only allowed when the query uses the
> GROUP BY
> clause.
>
> * The expression uses an alias to a column substring.
>
> Revise the SQL statement to follow these rules.
>
> I wish to select distinct data only.
> Please help me, thanks.