简体   繁体   中英

INITCAP function in Oracle SQL View

I have created a table view like this:

SELECT
   census_regions AS "Regions",
   all_markets AS "Markets",
   bc_department AS "Department",
   bc_super_category AS "Super Category",
   hw_organic AS "Organic"
FROM MY_TABLE
WHERE all_markets != 'unknown'

I'd like to "wrap" it into INITCAP function, so every value in my table would be Proper Case. But the renaming causes problems and I really need the columns to be renamed. I tried brackets, but it gives me errors anyway.

Thank you very much. Nikola

You do this one column at a time:

SELECT initcap(census_regions) AS Regions,
       initcap(all_markets) AS Markets,
       initcap(bc_department) AS Department,
       initcap(bc_super_category) AS "Super Category",
       initcap(hw_organic) AS Organic
FROM MY_TABLE
WHERE all_markets <> 'unknown';

Do not use escape column names unless you have to. I would recommend that you rename Super Category so there is no space in the name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM