I'm creating a database (information has been entered already) where I
want to count some subrecords linked by a record. An example:
TABLE1:
ID | TITLE
1 | TEST
2 | TEST2
TABLE2:
ID | PID | TITLE | SUBTOTAL
1 | 1 | 1a | 50
2 | 1 | 1b | 65
3 | 1 | 1c | 15
4 | 1 | 2a | 54
5 | 1 | 2b | 13
6 | 2 | 1a | 24
7 | 2 | 5a | 35
8 | 2 | 5b | 25
9 | 2 | 7 | 15
Okay, TABLE2.PID is linked to TABLE1.ID.
Now, my problem is: I want to count TABLE2.SUBTOTAL together, WHERE
TABLE2.TITLE starts with the same number (TABLE2.TITLE is always starts
with a number) AND WHERE PID is the same (for example, only WHERE PID =
1).
So, when executed, PID = 1, TABEL2.TOTAL = 130 (1a + 1b + 1c WHERE PID
= 1).
And, while I'm busy, I also want to know how much items there are with
PID = 1 AND TABLE2.TITEL.items starting with the same number. So, when
executed, PID = 1, there a 3 items starting with the same number 1, 2
items starting with the same number 2, etc.
I hope this is clear.
Thanks in advance,
Edwin Siebel 6 2213
Try this. Let me know and I can email you the db I created testing
this:
SELECT T1.ID, Left([T2]![Title],1) AS TitleBeginningCharacter,
Count(T2.ID) AS CountOfID, Sum(T2.SUBTOTAL) AS SumOfSUBTOTAL FROM
Table1 AS T1 INNER JOIN Table2 AS T2 ON T1.ID = T2.PID GROUP BY T1.ID,
Left([T2]![Title],1);
You can add a HAVING clause before the semi-colon to return just one
PID at a time:
....HAVING T1.ID = 1
Thanks,
Johnny
Johnny Meredith wrote: Try this. Let me know and I can email you the db I created testing this:
SELECT T1.ID, Left([T2]![Title],1) AS TitleBeginningCharacter, Count(T2.ID) AS CountOfID, Sum(T2.SUBTOTAL) AS SumOfSUBTOTAL FROM Table1 AS T1 INNER JOIN Table2 AS T2 ON T1.ID = T2.PID GROUP BY T1.ID, Left([T2]![Title],1);
You can add a HAVING clause before the semi-colon to return just one PID at a time:
...HAVING T1.ID = 1
Thanks, Johnny
Excellent Johnny, although I haven't tested it yet, but thanks. I've
been struggling with this one for a while now. If possible, I'm
interessed in the db, you can just send it to edwin@heppie*removethis*.nl (without the *removethis*).
Thanks!
Edwin
Johnny Meredith wrote: Try this. Let me know and I can email you the db I created testing this:
SELECT T1.ID, Left([T2]![Title],1) AS TitleBeginningCharacter, Count(T2.ID) AS CountOfID, Sum(T2.SUBTOTAL) AS SumOfSUBTOTAL FROM Table1 AS T1 INNER JOIN Table2 AS T2 ON T1.ID = T2.PID GROUP BY T1.ID, Left([T2]![Title],1);
You can add a HAVING clause before the semi-colon to return just one PID at a time:
...HAVING T1.ID = 1
Thanks, Johnny
Excellent Johnny, although I haven't tested it yet, but thanks. I've
been struggling with this one for a while now. If possible, I'm
interessed in the db, you can just send it to edwin@heppie*removethis*.nl (without the *removethis*).
Thanks!
Edwin
Johnny, it works perfect!!! Absolutely wicked.
One more question: do you know how to get another column (for example
name "AVG") with SumOfSUBTOTAL / CountOfID? I tried to do it in an
EXPRESSION, but it didnt' work.
Thanks
I'm out of the office until Tuesday. I'll send you the db and answer
your question at that time.
heppie.nl wrote: Johnny, it works perfect!!! Absolutely wicked.
One more question: do you know how to get another column (for example name "AVG") with SumOfSUBTOTAL / CountOfID? I tried to do it in an EXPRESSION, but it didnt' work.
Thanks
Johnny, it works, also the AVG, so no absolute need of sending the
database.
Thanks, I owe you a beer :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hari Om |
last post by:
Here are the details of my error log files:
I execute the command and get following message at console:
----------------------------------------------------------------------
../sqlldr...
|
by: thomasp |
last post by:
I am trying to get a record count of a PHP query on a MS Acess database
using ODBC with a DSN for MS ACCESS connection. I got this code from the
PHP manual user notes. It seems to return the...
|
by: Ryan |
last post by:
I've got a problem I have't run up against before. I generally test
for an empty recordset using BOF and EOF. Today, for the first time I
ran into a problem where my recordset shows BOF and EOF =...
|
by: darrel |
last post by:
I'm trying to whip up a fancy repeater control that will put records into a
two-column table for me.
This is how I envision it working:
itemtemplate
if record count = odd then write out the...
|
by: Mike |
last post by:
I have a form where I have turned off the default navigation buttons. I
then created my own. This works fine. The only questions that I have is on
the default navigation buttons it shows total...
|
by: Peter W Johnson |
last post by:
Hi guys,
I have a problem with a datagrid record count. Here is the code:-
<snip>
Public Class frmMerchantDeposit
Inherits System.Windows.Forms.Form
Dim myconnection As New...
|
by: MP |
last post by:
vb6,ado,mdb,win2k
i pass the sql string to the .Execute method on the open connection to
Table_Name(const) db table
fwiw
(the connection opened via class wrapper:)
msConnString = "Data Source="...
|
by: sparks |
last post by:
I have always just got a count on records and put up a box at the top
of the entry forms saying something like 1 of 500 and updating it as
you got to 500 of 500.
I have never thought of this as...
|
by: AccessHunter |
last post by:
Hi,
I have a table with the type of data as below,
sorted as follows, Case (ascending), Loc (ascending) and Transaction Date (ascending).
CASE LOC TRANSACTION DATE FACILITY...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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: 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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |