473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2003, how do I show "zero" values in a query, where the field is calculated?

2 New Member
SELECT Dates.[Game Date], Sum(1) AS [Adj Away Wins]
FROM Dates LEFT JOIN [NBA Table] ON Dates.[Game Date] = [NBA Table].[Date of Game]
WHERE ((([NBA Table].[Home Score])<[Adj Away Score]))
GROUP BY Dates.[Game Date];

I'm doing a sports database, for entertainment and to learn Access, so hopefully this is an easy fix. I have a Dates table, with each date of the year. I have another table with raw game data for each basketball game.

Let's say one day there are 5 games. Let's also assume that all 5 of these games are won by the "Home Team". Because "Away Team" has 0 wins on this date, when I SUM the total for this given date, it's 0 and will not show up in my query. I want the 0 to be present, so that later on I can run mathematical operations on this number.

I was able to use an IIf statement on other queries, where no calculations were done, but can't figure this one out.

Thanks in advance and let me know if I need to post more.
Dec 21 '09 #1
4 11275
Delerna
1,134 Recognized Expert Top Contributor
I think I follow your design ?


How about this
Expand|Select|Wrap|Line Numbers
  1. SELECT a.[Game Date], 
  2.        Sum(  IIF( b.[Home Score] < b.[Adj Away Score] , 1 , 0 
  3.            ) AS [Adj Away Wins]
  4. FROM Dates a
  5. LEFT JOIN [NBA Table] b ON a.[Game Date] = b.[Date of Game]
  6. GROUP BY [Game Date];
  7.  
There would be otherways too.
Some will run faster than others.
Maybe you should try to find a few other ways and see which performs best
Dec 22 '09 #2
Delerna
1,134 Recognized Expert Top Contributor
Oh, and the real reason that the dates that had no away wins were missing was because of this

WHERE ((([NBA Table].[Home Score])<[Adj Away Score]))

which filters every record, where the away team lost, out of the result, prior to doing the aggregation.
So if no away team won on a particular date then every record for that date
gets filtered out of the result.

That filtering occurred before the sum() so its really not because the sum equalled 0.
I know what you mean though.
Dec 22 '09 #3
WolverYanks
2 New Member
Thanks a bunch. This info was right on. I never thought to embed the IIF inside the SUM expression.

Thanks again!
Dec 22 '09 #4
MrDeej
157 New Member
Even simpler. In the query put "nz([calculated field];0)"

";0" or ";anything" will show if [calculated field] is null
Dec 22 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
1738
by: PeteCresswell | last post by:
I was happily coding along, putting some calculation results (rolling annualized rates of return - too compute-intensive to calculate on-the-fly - had tb staged beforehand via a batch job) into Double fields. Now, the clients have just dropped a litle bomb: they want to see "(NA)" if the calculation failed due to insufficient input data. That means our fields can have three kinds of values:
13
3977
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate button "Unexpected Error":3251 operation is not supported for this type of object.The demo cd has two databases, one is called inventory and the other just has the tables for the design called inventory data. When you run inventory the database works...
1
6476
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
7
16349
by: PW | last post by:
Hi, I have a form with unbound fields on it. The user selects a record from a recordset and I populate the unbound fields. When I try to change the unbound quantity text box, Access 2003 tells me "The data has been changed. Another user edited this record and saved the changes before you attempted to save your changes. Re-edit the record." This does not always happen. And yes, I can re-edit the quantity text
2
3984
by: Angus | last post by:
I am trying to change the selection in Javascript - but this HTML element is not a standard option control. On the web page it looks like a dropdown list - and you click on the right hand down arrow and you see the entries in a dropdown. But how would I control this thing from javascript? Here is the HTML: <div class="selection" style="top:0; left:89; width:159; height:21;"
3
1650
by: roger.dunham | last post by:
Hi there, I am writing an application that performs calculations on records within a data table. There may be many records in a data table. There are situations where the calculation may not be able to return a meaningful value (e.g. Divide by zero) and null (or other default) is returned instead. This is not a fatal error, so processing can continue on the rest of the data table. As such, the table may ultimately end up with a...
5
5297
by: Spetman | last post by:
I’m having trouble using MS Access 2003 to accomplish something that I thought would be relatively easy: I’m trying to create a query that will give me the projected balance of an account (such as a 401K account) at each year in the future, which is growing at a fixed rate of X% a year and which also gets additional, lump sum contributions each year. For example, let’s assume you start with a balance of zero and have these annual...
4
2657
by: daved | last post by:
SOLUTION NEEDED FOR ACCESS 2003 / VBA, NOT FOR ANY VERSION OF VB. I need to differentiate between the Enter key on the main keyboard and the numeric keypad and obviously tried using vbkeySeparator in the form’s Keypress event. However, both Enter keys return KeyCode 13. MS Q188550 (below) offers a workaround for VB only – it does not claim to fix VBA. On this basis you might expect that the bug is fixed in Access/VBA but it isn’t. I...
1
2849
by: katanah | last post by:
I am using Access, 2003. I have an entry form (single form) with a date field. I would like the user to be able to enter: 115 08 and have Access store and display the date as: 11/05/08, even though the zero was not entered. I am familiar with customizing formats and input masks, but cannot find any hint in the help section of how to achieve this. Is it possible? Maybe using VB (I am a novice at VB)? Thanks
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.