473,837 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting Count(*) From Left side of Join using WHERE on right side of join

Hi,

I have 2 tables: tblStatements and tblLines (one to many) Any
tblStatements record can have many associated records in tblLines.
The search criteria is against tblLines (ie tblLines.fldDat eofService
>= '6/1/06' and tblLinesfldDate ofService < '7/1/06'.) I join by tblStatements.f ldStatementPK and
tblLInes.fldSta tmentID (one to many)

I need to return a recordset that will look like (after i pass the
date range)

Total Statements Total Lines
136 1,123
24 869

the problem i get when i join the two tables is that i get this:

Total Statements Total Lines
1,123 1,123
869 869

any help or direction would be greatly appreciated.

Jul 3 '06 #1
2 1462
I think that COUNT(distinct tblStatements.f ldStatementPK) will do what
you want. This assumes a single-column PK for the Statements table.

Roy Harvey
Beacon Falls, CT

On 3 Jul 2006 05:17:43 -0700, pa********@gmai l.com wrote:
>Hi,

I have 2 tables: tblStatements and tblLines (one to many) Any
tblStatement s record can have many associated records in tblLines.
The search criteria is against tblLines (ie tblLines.fldDat eofService
>>= '6/1/06' and tblLinesfldDate ofService < '7/1/06'.) I join by tblStatements.f ldStatementPK and
tblLInes.fldSt atmentID (one to many)

I need to return a recordset that will look like (after i pass the
date range)

Total Statements Total Lines
136 1,123
24 869

the problem i get when i join the two tables is that i get this:

Total Statements Total Lines
1,123 1,123
869 869

any help or direction would be greatly appreciated.
Jul 3 '06 #2
Roy,

Thank you so much. That worked perfectly!

thanks,
Paul

Jul 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3463
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes in trees which form parent-child relationships, sort of like newsgroups. For example, the parent_id field points to another element. Indent_level is there for denormalization purposes, to avoid costly recursive issues in querying. The...
0
1403
by: Brent | last post by:
In the usual case, this SQL select count(*) from mytable where ... returns an accurate count of the rows you want. But how do I go about counting rows from this SQL (the sum...if statements function as a pseudo pivot query)?
22
12508
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=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
7
4449
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
9846
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
10890
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10581
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...
0
10279
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
9416
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
5855
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4479
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
4053
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3127
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.