![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I got 'Invalid Column Name NewCol1' when I query the following: Select col1, col2, (some calculation from the fields) as NewCol1, (some calculation from the fields) as NewCol2, NewCol1 = NewCol2 from Table1 inner join Table2 inner join Table3.... Where ..... Basically, I want to find out if NewCol1 = NewCol2 after the calculation |
#3
| |||
| |||
|
|
sweetpota... (AT) yahoo (DOT) com wrote: I got 'Invalid Column Name NewCol1' when I query the following: Select col1, col2, (some calculation from the fields) as NewCol1, (some calculation from the fields) as NewCol2, NewCol1 = NewCol2 from Table1 inner join Table2 inner join Table3.... Where ..... Basically, I want to find out if NewCol1 = NewCol2 after the calculation You can try this: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when NewCol1 = NewCol2 then 'equal' else 'not equal' end but I don't think that works. This should definitely work: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when (...) = (...) then 'equal' else 'not equal' end |
#4
| |||
| |||
|
|
On Jun 26, 12:16 pm, Ed Murphy <emurph... (AT) socal (DOT) rr.com> wrote: sweetpota... (AT) yahoo (DOT) com wrote: I got 'Invalid Column Name NewCol1' when I query the following: Select col1, col2, (some calculation from the fields) as NewCol1, (some calculation from the fields) as NewCol2, NewCol1 = NewCol2 from Table1 inner join Table2 inner join Table3.... Where ..... Basically, I want to find out if NewCol1 = NewCol2 after the calculation You can try this: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when NewCol1 = NewCol2 then 'equal' else 'not equal' end but I don't think that works. This should definitely work: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when (...) = (...) then 'equal' else 'not equal' end I just want to avoid the calculation again when it is already there as my query takes a while to run already. |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
On Jun 26, 12:16 pm, Ed Murphy <emurph... (AT) socal (DOT) rr.com> wrote: sweetpota... (AT) yahoo (DOT) com wrote: I got 'Invalid Column Name NewCol1' when I query the following: Select col1, col2, (some calculation from the fields) as NewCol1, (some calculation from the fields) as NewCol2, NewCol1 = NewCol2 from Table1 inner join Table2 inner join Table3.... Where ..... Basically, I want to find out if NewCol1 = NewCol2 after the calculation You can try this: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when NewCol1 = NewCol2 then 'equal' else 'not equal' end but I don't think that works. This should definitely work: select col1, col2, (...) as NewCol1, (...) as NewCol2, case when (...) = (...) then 'equal' else 'not equal' end I just want to avoid the calculation again when it is already there as my query takes a while to run already. |
![]() |
| Thread Tools | |
| Display Modes | |
| |