Unix Technical Forum

PostgreSQL

This is a discussion on PostgreSQL within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> In a Union query, I have initialized one new column for sorting purpose. For ex : select ORD = ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:14 PM
Venkat
 
Posts: n/a
Default PostgreSQL

In a Union query, I have initialized one new column for sorting purpose. For
ex :

select ORD = 1 , t1.a, t1.b from table1 as t1
Union
select ORD = 0, t2.a, t2.b from table2 as t2
order by ORD.

ORD column is not present in thw table. It is used here for putting all the
rows of the second query before the rows of first query. The query is
getting executed in Windows which uses SQL 2000 server. But in Linux(RedHat)
when we are using PostgresSQL database, the same query gives error - "Unable
to parse 'ORD' ".

Is this thing not supported in PostgresSQL? If this is not supported then
what is the method of acheiving the same result?


Thanks,
Venkat



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:14 PM
Jacco Schalkwijk
 
Posts: n/a
Default Re: PostgreSQL

Try:

select 1 AS ORD , t1.a, t1.b from table1 as t1
Union
select 0, t2.a, t2.b from table2 as t2
order by ORD

column_alias = expression is T-SQL specific and not ANSI-SQL standard, as
opposed to expression AS column_alias which is standard SQL.


--
Jacco Schalkwijk
SQL Server MVP


"Venkat" <venkat_kp@yahoo.com> wrote in message
news:1092226310.253625@sj-nntpcache-5...
> In a Union query, I have initialized one new column for sorting purpose.
> For
> ex :
>
> select ORD = 1 , t1.a, t1.b from table1 as t1
> Union
> select ORD = 0, t2.a, t2.b from table2 as t2
> order by ORD.
>
> ORD column is not present in thw table. It is used here for putting all
> the
> rows of the second query before the rows of first query. The query is
> getting executed in Windows which uses SQL 2000 server. But in
> Linux(RedHat)
> when we are using PostgresSQL database, the same query gives error -
> "Unable
> to parse 'ORD' ".
>
> Is this thing not supported in PostgresSQL? If this is not supported then
> what is the method of acheiving the same result?
>
>
> Thanks,
> Venkat
>
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:15 PM
Venkat
 
Posts: n/a
Default Re: PostgreSQL

"Jacco Schalkwijk" <jacco.please.reply@to.newsgroups.mvps.org.invalid > wrote
in message news:#YjU$q7fEHA.2848@TK2MSFTNGP10.phx.gbl...
> Try:
>
> select 1 AS ORD , t1.a, t1.b from table1 as t1
> Union
> select 0, t2.a, t2.b from table2 as t2
> order by ORD
>
> column_alias = expression is T-SQL specific and not ANSI-SQL standard, as
> opposed to expression AS column_alias which is standard SQL.
>
>


Thanks Jacco it worked for me.


regards,
Venkat



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com