我正在尝试在sql server中创建一个视图,如下所示:
CREATE VIEW HeaquartersSales AS SELECT gs.district, gs.MonthToDateSales, FROM GlobalSales AS gs GO
不过,我只想把销售数字算进去 MonthToDateSales 如果地区名称中有“g0-”。我该怎么做呢?
MonthToDateSales
qcbq4gxm1#
你好像在找一个 CASE 表达式:
CASE
CREATE VIEW HeaquartersSales AS SELECT district, CASE WHEN district like '%G0-% THEN MonthToDateSales END as MonthToDateSales FROM GlobalSales AS gs GO
1条答案
按热度按时间qcbq4gxm1#
你好像在找一个
CASE
表达式: