Convert or use expression in Sql select statement
-
Hi, I have the following expression which either I want to execute in Select statement and get the result into a variable or some tables column anything is fine or I want to convert it into Select statements case anything which is possible please let me know, I need this friends.
MCTR_DESCR == "Large" ? "LG" : MCTR_DESCR == "Midsize" ? "LG" : MCTR_DESCR == "Strategic Account" ? "LG" : MCTR_DESCR == "Strategic National" ? "LG" : MCTR_DESCR == "Large National" ? "LG" : MCTR_DESCR == "Small" ? "SG" : ISNULL([Copy of Column 11]) ? "SG" : [Copy of Column 11] == "" ? "SG" : LEFT([Copy of Column 11],1) == "X" ? "IFP" : [Copy of Column 11] == "W0051412" ? "Calpers" : [Copy of Column 11] == "W0051411" ? "Calpers" : "SG"
Thanks in advance buddies, Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
Hi, I have the following expression which either I want to execute in Select statement and get the result into a variable or some tables column anything is fine or I want to convert it into Select statements case anything which is possible please let me know, I need this friends.
MCTR_DESCR == "Large" ? "LG" : MCTR_DESCR == "Midsize" ? "LG" : MCTR_DESCR == "Strategic Account" ? "LG" : MCTR_DESCR == "Strategic National" ? "LG" : MCTR_DESCR == "Large National" ? "LG" : MCTR_DESCR == "Small" ? "SG" : ISNULL([Copy of Column 11]) ? "SG" : [Copy of Column 11] == "" ? "SG" : LEFT([Copy of Column 11],1) == "X" ? "IFP" : [Copy of Column 11] == "W0051412" ? "Calpers" : [Copy of Column 11] == "W0051411" ? "Calpers" : "SG"
Thanks in advance buddies, Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
If you are using MS-SQL, check this out ... https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql
-
Hi, I have the following expression which either I want to execute in Select statement and get the result into a variable or some tables column anything is fine or I want to convert it into Select statements case anything which is possible please let me know, I need this friends.
MCTR_DESCR == "Large" ? "LG" : MCTR_DESCR == "Midsize" ? "LG" : MCTR_DESCR == "Strategic Account" ? "LG" : MCTR_DESCR == "Strategic National" ? "LG" : MCTR_DESCR == "Large National" ? "LG" : MCTR_DESCR == "Small" ? "SG" : ISNULL([Copy of Column 11]) ? "SG" : [Copy of Column 11] == "" ? "SG" : LEFT([Copy of Column 11],1) == "X" ? "IFP" : [Copy of Column 11] == "W0051412" ? "Calpers" : [Copy of Column 11] == "W0051411" ? "Calpers" : "SG"
Thanks in advance buddies, Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
SELECT CASE WHEN MCTR_DESCR IN ('Large', 'Midsize') THEN 'LG' ELSE '' END ...
etc. Just build it out. It's all pretty straightforward.
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.