computer science & engineering 2111 cse 2111 lecture nz function 1cse 2111 nz function

6
Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1 CSE 2111 NZ Function

Upload: olivia-morris

Post on 13-Dec-2015

226 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function

1

Computer Science & Engineering 2111

Computer Science & Engineering 2111

CSE 2111 LectureNZ Function

CSE 2111 NZ Function

Page 2: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 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.

Page 3: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function

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?

Page 4: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function

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.

Page 5: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function

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…..

Page 6: Computer Science & Engineering 2111 CSE 2111 Lecture NZ Function 1CSE 2111 NZ Function

CSE 2111 NZ Function 6

Finally!