Home » SQL & PL/SQL » SQL & PL/SQL » Column Alias
Column Alias [message #336056] Thu, 24 July 2008 11:29 Go to next message
acarella
Messages: 21
Registered: July 2008
Location: Latham, NY
Junior Member
I have written this query and need to add a column to display PDF on the first query and then a colujmn to display HTML on the second query. How would I do this?

SELECT f_product, f_product_name, f_date_revised, f_custom1, f_custom3, f_format,
f_subformat, f_plant, f_language
FROM t_pdf_msds
WHERE f_authorized = '3'
UNION ALL
SELECT f_product, f_product_name, f_date_revised, f_custom1, f_custom3, f_format,
f_subformat, f_plant, f_language
FROM t_html_msds
WHERE f_authorized = '3'
ORDER BY f_product
Re: Column Alias [message #336059 is a reply to message #336056] Thu, 24 July 2008 11:40 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Add the column in both queries.

Regards
Michel
Re: Column Alias [message #336062 is a reply to message #336059] Thu, 24 July 2008 11:43 Go to previous messageGo to next message
acarella
Messages: 21
Registered: July 2008
Location: Latham, NY
Junior Member
how do I do that? It isn't an actual column, I am making it up
Re: Column Alias [message #336063 is a reply to message #336056] Thu, 24 July 2008 11:44 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Do you have something like this in mind?
SQL> select 'PDF' what, dname, loc
  2    from dept
  3  union all
  4  select 'HTML', dname, loc
  5    from dept
  6  ;

WHAT DNAME          LOC
---- -------------- -------------
PDF  ACCOUNTING     NY
PDF  RESEARCH       DALLAS
PDF  SALES          CHICAGO
PDF  OPERATIONS     BOSTON
HTML ACCOUNTING     NY
HTML RESEARCH       DALLAS
HTML SALES          CHICAGO
HTML OPERATIONS     BOSTON

8 rows selected.

SQL>
Re: Column Alias [message #336064 is a reply to message #336063] Thu, 24 July 2008 11:46 Go to previous message
acarella
Messages: 21
Registered: July 2008
Location: Latham, NY
Junior Member
Thank you very much.
Previous Topic: sql error
Next Topic: Help on SQL QUERY.
Goto Forum:
  


Current Time: Fri Dec 09 17:53:24 CST 2016

Total time taken to generate the page: 0.21193 seconds