Home > Back-end >  Why ' ' was used in select statement
Why ' ' was used in select statement

Time:01-18

Came across this code today:

SELECT 'Overall' as Main,
        wave,
        country,
        catg,
        '' AS hw,
        SUM(0) AS headwinds_sum
....
....

Can someone explain what ' ' in the above stands for? Its not a typo as it is repeated @multiple instances.

Not a typo, no text was missed to add.

CodePudding user response:

'' as hw

adds a column named hw to your select query of type varchar that contains empty strings.

Depending on how you process the resultset afterwards this can make sense.

CodePudding user response:

The symbol is used to return an empty column in a result set. Users occasionally do this to match column counts in insert selects or when exporting data to Excel files and you want standard column names for capturing audit recommendations on data etc.

  • Related