Alias name

General discussion forum about all databases other than SqlBase.
FRBhote
India
Posts: 2217
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Alias name

Post by FRBhote » 06 Aug 2021, 07:17

Facing a problem Sqlbase vs Sqlserver.

Sqlbase:

SELECT INVOICE_NO, INVOICE_NO FROM INVOICE ORDER BY INVOICE_NO ; works fine

SELECT INVOICE_NO AS A, INVOICE_NO AS B FROM INVOICE ORDER BY A ; 01401 DLU ICN Invalid column name A

Sqlerver:

SELECT S_ID_NO, S_ID_NO FROM S_ID ORDER BY S_ID_NO Ambiguous column name 'S_ID_NO'

SELECT S_ID_NO AS A, S_ID_NO AS B FROM S_ID ORDER BY A works fine

Would appreciate any help for both to be compatible.

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 1462
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Alias name

Post by Igor Ivanovic » 06 Aug 2021, 08:06

AFAIK, the order clause accepts column names or numbers only, not an alias.
I think that SqlServer can also have column number in the order clause, so this should work:

Code: Select all

SQLBase
SELECT INVOICE_NO, INVOICE_NO FROM INVOICE ORDER BY 1
SqlServer
SELECT S_ID_NO AS A, S_ID_NO AS B FROM S_ID ORDER BY 1
Igor Ivanovic
Image

FRBhote
India
Posts: 2217
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Re: Alias name

Post by FRBhote » 06 Aug 2021, 11:00

Thanks! I had forgotten that.

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 2 guests