Results 1 to 3 of 3

Thread: Access problem - query with null fields

  1. #1
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default Access problem - query with null fields

    I have an aggregate query with the following joining:


    Code:
    SELECT qItem.referenceno, Sum(FolioItems.qty) AS SumOfqty, First(FolioItems.JACIF) AS FirstOfJACIF, First(qItem.description) AS FirstOfdescription, First(qItem.folioid) AS FirstOffolioid, Sum([qty]-[soldqty]) AS balance
    FROM (qItem LEFT JOIN SoldItems ON qItem.ID = SoldItems.itemID) INNER JOIN FolioItems ON qItem.ID = FolioItems.itemID
    GROUP BY qItem.referenceno;
    qItem.ID is joined to SoldItems.ItemID : 2. Include ALL items from qItem and only those from SoldItems where the joined fields are equal.

    qty and soldqty are both Total:sum and I have a field called balance: [qty]-[soldqty]

    Now this gives me a table that shows each item and how many sold, however where none is sold I get a null value, and this also gives me a null value for balance. How do I resolve this?
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  2. #2
    Join Date
    Jan 2005
    Posts
    252
    Rep Power
    0

    Default

    Quote Originally Posted by ramesh View Post
    I have an aggregate query with the following joining:


    Code:
    SELECT qItem.referenceno, Sum(FolioItems.qty) AS SumOfqty, First(FolioItems.JACIF) AS FirstOfJACIF, First(qItem.description) AS FirstOfdescription, First(qItem.folioid) AS FirstOffolioid, Sum([qty]-[soldqty]) AS balance
    FROM (qItem LEFT JOIN SoldItems ON qItem.ID = SoldItems.itemID) INNER JOIN FolioItems ON qItem.ID = FolioItems.itemID
    GROUP BY qItem.referenceno;
    qItem.ID is joined to SoldItems.ItemID : 2. Include ALL items from qItem and only those from SoldItems where the joined fields are equal.

    qty and soldqty are both Total:sum and I have a field called balance: [qty]-[soldqty]

    Now this gives me a table that shows each item and how many sold, however where none is sold I get a null value, and this also gives me a null value for balance. How do I resolve this?
    Not sure but - Try using a wildcard character before the expression and see if that helps...that should force the query to return non-null values...check also if one of your fields is a string...
    JA-MEK-I-CAN

  3. #3
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    I found the solution: The NZ command makes any null (non zero) field zero.

    SO I changed soldqty to =nz([soldqty]) and it worked out just fine.
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •