skip to Main Content

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.

2

Answers


  1. '' 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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search