General discussion


SQL Nested Queries

By dpcarlton ·

I am trying to do a SQL nested query where like following:

Select * FROM (SELECT TOP 23 PERCENT convert(varchar,cast(dateCommInstalled as datetime),10) AS dateCommInstalled, COUNT(retNum) AS countofretnum, Row_Number() Over (order by dateCommInstalled ASC) as row FROM TABLE1 BY dateCommInstalled HAVING (dateCommInstalled IS NOT NULL) ORDER BY cast(dateCommInstalled as datetime)) order by datecomminstalled DESC

But, SQL (2005) does like this sort of nested query. What I trying to do is basically get a set of results, sorted in DESC order, then reverse the order.

Any help is appreciated.


This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

ASC order

by john.a.wills In reply to SQL Nested Queries

If you want to get the result of reversing a DESC sort, why not do an ASC sort in the first place.

Your code as shown is not very enlightening.

Collapse -

Needs a dummy table name fior the nested part

by Tony Hopkinson In reply to SQL Nested Queries

Select * from (..nested..) dummytable Where ...

Doesn't matter what dummytable is as long as it's a valid table name. It not being there is something the parser won't cope with.

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums