所以我已经声明了一个变量@Location。我想根据变量从表中的1列返回特定数据。
喜欢这个......
如果@Location ='Pennsylvania',则返回此列中以'123'开头的所有字段 IF @ Location ='New York,然后返回此列中以'345'开头的字段 这就是我到目前为止所写的内容,不确定我是否正确接近......
SELECT
CASE WHEN @Site = 'PEnnsylvania' THEN
(
SELECT A.so_prod_key
FROM so_prod_tbl A
WHERE A.so_prod_key LIKE '110%'
)
WHEN @Site = 'New York' THEN
(
SELECT B.so_prod_key
FROM so_prod_tbl B
WHERE B.so_prod_key LIKE '112%'
)
WHEN @Site = 'New Jersey' THEN
(
SELECT C.so_prod_key
FROM so_prod_tbl C
WHERE C.so_prod_key LIKE '111%'
)
ELSE ' ' END AS 'Products'
一点指导将不胜感激!
答案 0 :(得分:0)
该案例表达式可以像
一样进行更改var activityIndicator = UIActivityIndicatorView()
let loadingView = UIView()
let loadingLabel = UILabel()
答案 1 :(得分:0)
我认为这就是你想要的:
SELECT A.so_prod_key
FROM so_prod_tbl A
WHERE (@Site = 'Pennsylvania' and A.so_prod_key LIKE '110%') or
(@Site = 'New York' and A.so_prod_key LIKE '112%') or
(@Site = 'New Jersey' and A.so_prod_key LIKE '111%')
答案 2 :(得分:0)
我认为您想要的是以下内容,将case语句放在WHERE子句中:
SELECT A.so_prod_key
FROM so_prod_tbl A
WHERE A.so_prod_key LIKE (
CASE
WHEN @Site = ‘Pennsylvania’ THEN ‘110%’
WHEN @Site = ‘New York’ THEN ‘112%’
—- etc.
END
)
;