Avatar of Kiran_M
Kiran_M
 asked on

SQL Server 2005 - Using the derived value in the Select WHERE Condition

I am trying to use the derived value in the Select Statement Where condition as shown below :



Select  field a, field b,
  GetSomelList(tableA.field z) as Lista,   /* Where GetSomeList is a function
field c
from  tableA 
where  some condition AND  Lista <> ','
 
I get the error Lista is not a "table column' as expected because it is dervied 
 value and not a table column.
 
I can do this
 
Select  field a, field b,
  GetSomelList(tableA.field z) as Lista,  /* Where GetSomeList is a function
field c
from  tableA 
where  some condition AND  GetSomelList(tableA.field z)  <> ','
 
Is there a better way of do this  instead of calling the same function twice in the select statement.

Open in new window

Microsoft SQL ServerMicrosoft SQL Server 2005

Avatar of undefined
Last Comment
Kiran_M

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
aaronakin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Mark Wills

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Kiran_M

ASKER
aaronkin suggestion worked great for my case.  Mark_wills - thanks a lot for all the alternate solutions for other scenerios.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck