sql server 2008 - sql Alias Column Name for Use in CASE Statement -


itemprop = "text">

I have an SQL query as below,

  selected site, data source, (as select case when data source = 'RFQ' then 'ChangeOperator' balance 'SameOperator' end) OperatorScenario, the (select case OperatorScenario = 'ChangeOperator' then '1' Balance '022' end) OperatorScenario2 As tablename  

in the form when I execute this query, I get an exception in the form of invalid column name operator scanner, As tried by using a code in the other name in the second query,

  (if you choose the case 'OperatorScenario' = 'ChangeOperator' then '1' remaining '022' end) As OperatorScenario2   

Then it always implements the other part. Please give me some tips related sangeet

The main issue is that you do not reference the nickname in the same query Can give Also you have brackets and an additional SELECT keyword, which looks like a subclass where I do not believe you have one intention (you have FROM Do not block. / P>

You can copy the whole thing again (either fixing your query in the process):

  select site, data source, case When the data source = 'RFQ' then 'ChangeOperator' remaining 'Saooperator' and SS Operator SACNRI case Switch to in case when Datasors = 'RFQ' then 'Chenjropretr' Aelsi 'Saoopretr "end =" Chenjropretr' and '1' Ielsi as '022' Eddie the Tablenm from Opretrssenario 2   

Or, to simplify:

  select site, data source, case when the data source = 'rfQ' then 'ChangeOperator' remaining 'SameOperator' end operatorScenario, as the case when the data Source = 'RFQ' then '1' remaining '022' from Tablename  as END OperatorScenario2  

or a CTE (again Use query fixing):

  Select (site with CTE, Detasors case when Datasors = so 'RFQ' Chenjopretr 'EL SA' Saoopretr 'and SAS operator Sisanario, select Tablenem) site, Detasors operator Sisanario when Opretrsenario = 'Chenjropretr' and '1' Els '022' CT operator Senario 2 as Eddie    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -