user2994079
user2994079

Reputation: 13

SQL Server 2008 R2, Mixed arguments in a computed column

I'm a noob guys, so don't be too harsh.

New to the forum, read around and couldn't fin d an answer. Maybe someone here knows if this works or not.

Building a computed column in the management studio, We'll call it total. When I enter this equation, it works:

Liquor + Beer + Wine + Food + NonAlc

When I enter this equation it fails and returns null:

Liquor + Beer + Wine + Food + NonAlc + NonAlc - Voucher

All fields are identical data types (money). Can't get it to work with mixed arguments. Anyone have any suggestions for me?

Thanks in advance.

Upvotes: 1

Views: 63

Answers (2)

Amir Keshavarz
Amir Keshavarz

Reputation: 3108

Use this: Concat(Liquor , Beer ,Wine ,food ,NonAlc ,NonAlc - Voucher)

Upvotes: 0

M.Ali
M.Ali

Reputation: 69504

Do something like this

ISNULL(Liquor, 0) + ISNULL(Beer, 0) + ISNULL(Wine, 0) + ISNULL(Food, 0) 
      + ISNULL(NonAlc, 0) + ISNULL(NonAlc, 0) - ISNULL(Voucher, 0)

Upvotes: 1

Related Questions