Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing column in a view

Status
Not open for further replies.

clyde11

Programmer
Feb 6, 2006
25
GB
Hello all,
I'd like to create a view which shows all specific column values
(null values for example)
as calculated values from another column,
if for example i have the table:
---------------
| col1 | col2 |
|------|------|
| 123 | null |
| 126 | 9 |
---------------
i would like the view to be:

---------------
| col1 | col2 |
|------|------|
| 123 | 6 |
| 126 | 9 |
---------------

------> 6, since it's the sum of col1 digits 1+2+3


I don't really know how to do that, although i'm quite sure it's possible, any help will be appreciated,

Best Regards,
C.
 
Is Col1 Int or a string? and is it a specified length i.e will it always be length of 3 or is that variable, can the column be a null value
 
Thanks,

i figured this one out (with a little help from my friends..)
maybe i wasn't so clear, i wanted to change all the *NULL*
values to be a function of some other column, i solved it like this:

select col1, isnull( [col2], some_func( [col1] ) as col1
from table

-- when some_func is a function the parses the number in
-- col1....


Thanks a lot !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top