computer science & engineering 2111 cse 2111 lecture nz function 1cse 2111 nz function
TRANSCRIPT
1
Computer Science & Engineering 2111
Computer Science & Engineering 2111
CSE 2111 LectureNZ Function
CSE 2111 NZ Function
CSE 2111 NZ Function 2
Client Payments
Let’s take a closer look at the PaymentsByClient Query….in an outer join with respect to Clients, when a record from Clients doesn’t have any matching records in Payments, it’s included in the results, but the fields that would have come from Payments are NULL.
CSE 2111 NZ Function 3
Access doesn’t know what $100 – NULL is, so it returns NULL as the result.
But we know that in this case, NULL should be treated like zero – can we help Access out?
CSE 2111 NZ Function 4
NZ Function
Syntax: Nz(variant, value_if_null)
If this argument evaluates to NULL….
Return this value
If the variant argument does NOT evaluate to NULL, Nz will return whatever the variant argument does evaluate to.
CSE 2111 NZ Function 5
BalanceDue Tables: PaymentsByClient,ChargesByClientJoin On: ClientID Join Type: Inner
Field: ClientID FirstName LastName SumOfAmount SumOfAmount Balance*
Table: PaymentsByClient
PaymentsByClient
PaymentsByClient
PaymentsByClient
ChargesByClient
Total:
Sort:
Show: X X X X X X
Balance: Nz([Charges]![SumOfAmount],0) – Nz([Payments]![SumOfAmount],0)
Balance Due with the Nz function…..
CSE 2111 NZ Function 6
Finally!