Hi,
I'm working on a database where I need to calculate some data that fits
certain sets of parameters, but I'd like it to give me more information
than I know how to get.
As an example, let's say I'm querying a table with the following fields:
pmt_no pmt_amt staff_id
pmt_no is unique, but isn't being used in these calculations.
I've done a query that counts the number of payments as long as the
payment is more than 50:
SELECT tbl_accounts.staff_id, Count(tbl_accounts.pmt_amt) AS no_of_payments
FROM tbl_accounts
WHERE (((tbl_accounts.pmt_amt)>=50))
GROUP BY tbl_accounts.staff_id;
This works fine, as far as it's meant to: it gives me a list of all the
people who've had any payments >=50.
However, what I'd really like is maybe to link this with another table
that contains *all* staff_ids and, if they haven't had a payment of over
50, I'd like my query to give me a '0' next to that staff id.
Is this possible or am I hoping for too much? :)
(Please do let me know if anything is unclear - I tried to think of as
simple an example as possible; my real data is very slightly more
complex, but the principle is the same!)
Thank you for reading this far. ;)
-Jen (if you care to reply by email, remove the spork) 2 1370
Jen P. wrote:
Hi,
I'm working on a database where I need to calculate some data that fits
certain sets of parameters, but I'd like it to give me more information
than I know how to get.
As an example, let's say I'm querying a table with the following fields:
pmt_no pmt_amt staff_id
pmt_no is unique, but isn't being used in these calculations.
I've done a query that counts the number of payments as long as the
payment is more than 50:
SELECT tbl_accounts.staff_id, Count(tbl_accounts.pmt_amt) AS no_of_payments
FROM tbl_accounts
WHERE (((tbl_accounts.pmt_amt)>=50))
GROUP BY tbl_accounts.staff_id;
This works fine, as far as it's meant to: it gives me a list of all the
people who've had any payments >=50.
However, what I'd really like is maybe to link this with another table
that contains *all* staff_ids and, if they haven't had a payment of over
50, I'd like my query to give me a '0' next to that staff id.
Is this possible or am I hoping for too much? :)
(Please do let me know if anything is unclear - I tried to think of as
simple an example as possible; my real data is very slightly more
complex, but the principle is the same!)
Thank you for reading this far. ;)
-Jen (if you care to reply by email, remove the spork)
In the query builder drop both tables into it. Most likely there will
be a link line between StaffID in both tables. Dbl-Click on the line
and select "All recs from EmpTable and Matching recs from TblAccounts"
Drag the StaffID from tblAccounts. If it's null, then it'd be 0.
Salad wrote:
Jen P. wrote:
<snip>
>I've done a query that counts the number of payments as long as the payment is more than 50:
SELECT tbl_accounts.staff_id, Count(tbl_accounts.pmt_amt) AS no_of_payments FROM tbl_accounts WHERE (((tbl_accounts.pmt_amt)>=50)) GROUP BY tbl_accounts.staff_id;
This works fine, as far as it's meant to: it gives me a list of all the people who've had any payments >=50.
However, what I'd really like is maybe to link this with another table that contains *all* staff_ids and, if they haven't had a payment of over 50, I'd like my query to give me a '0' next to that staff id.
<snip>
In the query builder drop both tables into it. Most likely there will
be a link line between StaffID in both tables. Dbl-Click on the line
and select "All recs from EmpTable and Matching recs from TblAccounts"
Drag the StaffID from tblAccounts. If it's null, then it'd be 0.
Hurrah! Cheers for that. :) I ran into an 'Ambiguous outer join'
error, but I was able to fix that with a quick Google and help from:
<http://rogersaccessblog.blogspot.com/2008/09/ambiguous-outer-joins.html>
Many thanks for your quick and extremely helpful reply. :D
-Jen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Da-Breegster |
last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband,
tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a
problem regarding the data structure for the map and...
|
by: Raymond |
last post by:
Hi All:
To find a file exists using the file name, I have tow routings on UNIX
system.
1. access(2)
2. lstat(2)
This tow function also can do. When the return value is "-1" and errno
is...
|
by: StormyTheCat |
last post by:
Perhaps this is easy, but I'm new to C# am in need of some help.
I need to embed a CRC value into an XML file to be able to detect when the
data contained
therin is corrupted. Calculating the...
|
by: Bob Day |
last post by:
VS 2003, sql
How do you determine the data type of a column if its value is DBNull?
1)Table:
Column1 STRING non-nullable
2) Fill to a DataSet via DataAdapter
3) dim Data_Type_Is...
|
by: Anonieko |
last post by:
Here are some of the approaches.
1. Transform DataGrid
http://www.dotnetjohn.com/articles.aspx?articleid=36
3. Use the Export approach
...
| |
by: Wired Hosting News |
last post by:
I tried to be breif and give a scenario so as not to be overlooked because
it was soooo long. Let me give you real world.
I am a manufacturer of goods and produce 11 items that are distributed...
|
by: Arpan |
last post by:
The .NET Framework 2.0 documentation states that
An Object variable always holds a pointer to the data, never the data
itself.
Now w.r.t. the following ASP.NET code snippet, can someone please...
|
by: jdcrief |
last post by:
Complier: Visual C++ 2005 Express Edition
The program I wrote will compile and execute, but the output is always
the same, no matter what number is entered in for the radius of the
circle. ...
|
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= |
last post by:
Say I have a class like,
class Sample
{
public decimal first = 10;
public decimal second = 20;
}
I have initialized it
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
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...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |