I am using a stored procedure (SQL Server) from get value where @classtype is a parameter, I want to when classtype = p then classType value come from table but column name English or Other base on classtype, I am trying below code for get data but get error for:
AS not supported.
select
col
, col1
, CASE WHEN @classtype ='P' THEN classType AS 'English' ELSE classType as 'Other' END, col4
from my_table
Thanks.
2条答案
按热度按时间7z5jn7bk1#
You can use an
IF
statement to return a different resultset.Or dynamic SQL
mkshixfv2#
You can use dynamic SQL