Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

How to update view columns for certain rows

$
0
0

Hi,

I have created an SQL Server view, which amongst other things, it generates the following columns:

CASE 
WHEN 
                        ...conditions...
THEN Main.[ExpenseCategory]
END [ExpenseCategories],

It generates the following view (an extract):

ExpenseIDPropertyShareHolderIDExpenseCategoryExpenseCategories
37237Property PurchaseNULL
37231156Property PurchaseNULL
37457Property PurchaseNULL
37451156Property PurchaseNULL
37497Property PurchaseProperty Purchase
37491156Property PurchaseNULL
38017Property PurchaseProperty Purchase
38011156Property PurchaseNULL
38227Property PurchaseProperty Purchase
38229Property PurchaseNULL
38221156Property PurchaseNULL
38237Property PurchaseProperty Purchase
38231156Property PurchaseNULL
38247Property PurchaseProperty Purchase
382418Property PurchaseNULL
38241156Property PurchaseNULL
38257Property PurchaseNULL
382512Property PurchaseNULL
38251156Property PurchaseProperty Purchase
38377Building Labour & MaterialBuilding Labour & Material
38371156Building Labour & MaterialNULL
38517Building Labour & MaterialBuilding Labour & Material
38511156Building Labour & MaterialNULL
38737Building Labour & MaterialBuilding Labour & Material
38731156Building Labour & MaterialNULL


As you will note, the "conditions" are satisfied for only one member of the ExpenseID group where ExpenseCategories is set to ExpenseCategory and for all others in the same group it is set to NULL.

How can I set ExpenseCategories to the same value for all members of the same ExpenseID group?

Thanks for your help in advance.

Regards

Abbas


Abbas



Viewing all articles
Browse latest Browse all 7129

Trending Articles



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