473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

reusing column labels in select

Hello,

Is there any way to reuse a column label in a select list like this:

SELECT 1 + 1 AS a, a + 1 AS b;

I vaguely remember being able to do something like this in oracle. Any
ideas? Thanks!

~RvR
Nov 23 '05 #1
2 2520
There might be a better way then this but this works

SELECT a, a+1 as b from (SELECT 1+1 as a) as ab;
On 16 Oct 2004 11:18:48 -0700, ryan <rv*******@gmail.com> wrote:
Hello,

Is there any way to reuse a column label in a select list like this:

SELECT 1 + 1 AS a, a + 1 AS b;

I vaguely remember being able to do something like this in oracle. Any
ideas? Thanks!

~RvR

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
* ryan <rv*******@gmail.com> [2004-10-16 11:18:48 -0700]:
Is there any way to reuse a column label in a select list like this:

SELECT 1 + 1 AS a, a + 1 AS b;

I vaguely remember being able to do something like this in oracle. Any
ideas? Thanks!


You could nest them...

xinu=> select (1 + 1) + 1 as answer;
answer
--------
3
(1 row)

--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
2
by: Martin O'Rourke | last post by:
All, I am hoping someone might be able to put me out of my misery and let me know if it is possible or not to dervie the name of an element in a form, based on its associated label, only knowing...
0
by: dave jackson | last post by:
Hi, I'm formatting fields when creating my view and would like to reuse the existing labels. e.g. Create View TEST AS SELECT AMOUNT, CURRENCY, DIGITS(CUSTNO) AS PADCUSTNO, DATE(DAYNO) AS...
3
by: Paula | last post by:
I need to do a summary using a crosstab query. The data has a Date field (Not named "Date"). I can do the Row Heading and Value but am having trouble with the Column Heading. The summary Columns...
3
by: daveS | last post by:
I have come accross the exact same problem as below. The address that was given as a solution cannot be found. Specifically, i need to be able to show labels in only the first column of a report!...
10
by: Robert Schuldenfrei | last post by:
Hi NG: I have the following code working. The GetProdStrtList() returns a DataTable called psTable. A Grid control is successfully bound to this table and displays correctly. I would like to...
24
by: Mike Otten | last post by:
Any help greatly appreciated. The validated page is at: http://myweb.stedwards.edu/michaelo/ddtab.htm The trouble is with the radio buttons (2/3-down the left column). The radios are...
2
by: sks | last post by:
Hi all, Is possible to retrieve all columns and alias them all at once. Eg, normally you would write select * from products which would return id | name | price ----------------------- 1...
2
by: brazil.mg.marcus.vinicius.lima | last post by:
Hi, I'm constructing a query that will performs a lot o datetime calculumns to generate columns. All that operations are dependent of a base calculum that is performed on the query and its...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.