Home > database >  Field generated by the CASE WHEN statement, if as a condition into the query?
Field generated by the CASE WHEN statement, if as a condition into the query?

Time:11-11

SELECT
CASE
The WHEN DEPT_NAME='accessories department' THEN '0.01'
ELSE the SUBSTRING (DEPT_CODE, 0, CHARINDEX ('. ', DEPT_CODE, 8) + 3) END AS BMBH, DEPT_CODE, DEPT_NAME,
CASE
The WHEN BMBH=DEPT_CODE THEN DEPT_NAME
The ELSE
'other'
END AS tz
The FROM MS_Dept

================================
query resultsEND AS the brand name
The FROM MS_Dept
WHERE BMBH=0
[42 s22] [Microsoft] [10.0] SQL Server Native Client/SQL Server names' BMBH 'invalid, (207)

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Q: the new generation of BMBH column can't participate in terms? This column if the conditions are calculated?

CodePudding user response:

Can't make it; To write a select * from outside (the original) t where generated field=
  • Related