Home > Blockchain >  Databrick adding column with with column in select statement
Databrick adding column with with column in select statement

Time:11-07

In SQL Server we can create new column by adding some value like below

select *, new_column = fixed_value 
from table 

I want to replicate this in Databricks SQL, but in Databricks I'm getting an error "new_column is not present".

How to do this in Databricks for temp table?

CodePudding user response:

in databricks you use aliases, which you also can use in sql server and other rdms

 select *,  1 as new_column from table 

CodePudding user response:

you can always hardcode columns:

select 
  *, 
  'john' as name, 
  'us' country, 
  9999 as population 
from  <table_name>
  • Related