Oracle SQL视图中的INITCAP函数

时间:2019-02-28 14:54:12

标签: sql oracle view

我创建了这样的表格视图:

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'

我想将其“包装”到INITCAP函数中,因此表中的每个值都应为“正确大小写”。但是重命名会导致问题,我确实需要将列重命名。 我尝试了方括号,但无论如何还是给了我错误。

非常感谢。 尼古拉

1 个答案:

答案 0 :(得分:0)

您一次执行一列:

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';

除非必须,否则不要使用转义列名称。我建议您重命名Super Category,以便名称中没有空格。