Home » SQL & PL/SQL » SQL & PL/SQL » creating column heading as a literal string
creating column heading as a literal string [message #1774] Tue, 28 May 2002 19:35 Go to next message
jack
Messages: 123
Registered: September 2000
Senior Member
I am doing a union query to show price increases. I need to create a column (in the first postion) that shows the % of the increase (as "INC"). The first Select stmt would have 10%, the next 12%, and so forth.

I know I need to create a literal string, but I am not sure how. Can someone help?

Thanks!

Here is the script.

SELECT bCODE as "Code", price as "Price", price * 1.1 AS "New Price"
FROM b_book
where price > 30
UNION
SELECT bCODE, price, price * 1.12
FROM b_book
where price between 15 and 29.99
UNION
SELECT bCODE, price, price * 1.15
FROM b_book
where price between 10 and 14.99
UNION
SELECT bCODE, price, price * 1.2
FROM b_book
where price < 10;
Re: creating column heading as a literal string [message #1775 is a reply to message #1774] Tue, 28 May 2002 22:09 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
I don't see the problem, but is this what you're looking for?

1 select ' 0 %' INC
2 , sal
3 , 'A' x
4 from emp
5 where empno = 7369
6 union
7 select '10 %'
8 , sal*1.1
9 , 'B'
10 from emp
11* where empno = 7369
SQL> /

INC SAL X
---- ---------- -
0 % 800 A
10 % 880 B

SQL>

MHE
Previous Topic: How to compare 2 values of Long Datatype
Next Topic: triggers
Goto Forum:
  


Current Time: Fri Apr 19 22:29:48 CDT 2024