Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Populate a column based on if it's null or not..!

$
0
0

Hello Gurus, 

I'm trying to populate a column based on if it's null or not. 

If it's null i want to populate with another column values. If it's not null then populate with the same column value. 

I wrote the query like below but I'm getting error saying 'SQL command not properly ended'


select school_id, class_id  from school
     where class_id= case when class_id  IS NOT NULL  then class_id  
                when class_id    IS  NULL thenschool_id
                end as class_id

 

Please help me!! Thanks


Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>