Link to home
Start Free TrialLog in
Avatar of beechers
beechersFlag for United States of America

asked on

Need to add dummy column in query with no data values in result

I want to do a SQL query in Oracle that will add a dummy column with no data in the column. I can do the following:  select file_num, name, 'dummy_column' from pd_file where file_num = '123456'. But the result comes up with a 'dummy_column' column with 'dummy_column' as the value for that field in every row.  I saw a question here with the answer being to do the follwwing:
select file_num, name,  null 'dummy_column' from pd_file where file_num = '123456'.

When I do that I get the following error:  "ORA-00923: FROM keyword not found where expected".

I am sure there must be a way to do this simple thing.  Thanks for your advice!
Susan
ASKER CERTIFIED SOLUTION
Avatar of dqmq
dqmq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of anokun7
anokun7

you can also use a blank string like below:

SQL> desc applications
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 APPLICATION_ID                            NOT NULL VARCHAR2(12)
 APPLICATION_NAME                          NOT NULL VARCHAR2(50)
 APPLICATION_DISPLAY_NAME                  NOT NULL VARCHAR2(256)

SQL> select application_id, '' nothing from applications;

APPLICATION_ N
------------ -
3M
ABS
AC
AD
BACSTEL
BAL
BKS
BLR
BWR
SOLUTION
Avatar of jwahl
jwahl
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beechers

ASKER

Thank you all so much!  I knew there had to be a simple solution!