473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Delaut values in a query if no record in table

I am using a select query to sum 2 fields in another select query, but if their are no records and the first select is empty I get a blank. I would like to get a zero if this happens. is this possible?

I am using Access 2007

select query 1
SELECT Trans.[LABOR$], Trans.[LBR-COST$], Trans.[Close-Date]
FROM Trans
WHERE (((Trans.[Close-Date])=Date()-1) AND ((Trans.[LBR-TYPE])="CCB"));


select query 2
SELECT Sum(BSLaborDaily.[LABOR$]) AS [SumOfLABOR$], Sum(BSLaborDaily.[LBR-COST$]) AS [SumOfLBR-COST$]
FROM BSLaborDaily;
Aug 4 '07 #1
1 1559
FishVal
2,653 Expert 2GB
I am using a select query to sum 2 fields in another select query, but if their are no records and the first select is empty I get a blank. I would like to get a zero if this happens. is this possible?

I am using Access 2007

select query 1
SELECT Trans.[LABOR$], Trans.[LBR-COST$], Trans.[Close-Date]
FROM Trans
WHERE (((Trans.[Close-Date])=Date()-1) AND ((Trans.[LBR-TYPE])="CCB"));


select query 2
SELECT Sum(BSLaborDaily.[LABOR$]) AS [SumOfLABOR$], Sum(BSLaborDaily.[LBR-COST$]) AS [SumOfLBR-COST$]
FROM BSLaborDaily;
Hi!

Try to use the following SQL for the 2nd query

SELECT Nz(Sum(BSLaborDaily.[LABOR$]),0) AS [SumOfLABOR$], Nz(Sum(BSLaborDaily.[LBR-COST$]),0) AS [SumOfLBR-COST$]
FROM BSLaborDaily;
Aug 4 '07 #2

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

Similar topics

4
by: Steve Hall | last post by:
Folks, My secnario involves two tables - ObservationRegister, and Person. ObservationRegister contains most of the "useful" fields, including the UserID of the person that raised the record, and...
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
3
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending...
0
by: Jeff Boes | last post by:
I hope this helps someone else ... I had struggled some time ago with attempts to get a rank of values query to work, but then I gave up and set it aside. I had another reason to attack it, and in...
4
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index...
2
by: dancole42 | last post by:
So I have a subform that lists the various items on a particular invoice. First, the user selects a product class from the Class dropdown. This is bound to the Class field in the InvioceLines...
3
by: wenggarcia | last post by:
please help me.. kindly see if what's wrong with my code below.. im trying to insert values in a table on my database but the query returned as failed. html code -my input page <form...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
12
by: Michel Esber | last post by:
Hello, Db2 Linux LUW FP 15. Consider table A (ID varchar, EXECUTION_DATE date). a) I want to first retrieve all IDs that have not executed during the last 90 days: select distinct ID...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...

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.