Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 23rd, 2003, 08:08 AM
Authorized User
Join Date: Oct 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default join two counts field

I have two recordsets that I am counting the data from the same table with different search criteria. I would like to join Org, FinApp, RootCause in the one table. Could you help me how to do that?


Here is the my select statements that I am counting the data from database:

strListFinAppCounts = "SELECT strOrg as Org,count(nID) as FinApp from tblCycleCount where dDateApproved = 'n/a' and dDateRecount = 'n/a' and (dDateRejected = 'n/a' or dDateRootCaused <> 'n/a') group by strOrg"
set rsListFinAppcounts = Server.CreateObject("ADODB.Recordset")
rsListFinAppCounts.Open strListFinAppCounts, oConn1

strListRootCounts = "SELECT strOrg as Org,count(nID) as RootCause from tblCycleCount where dDateApproved = 'n/a' and dDateRejected <> 'n/a' and dDateRootCaused = 'n/a' group by strOrg"
set rsListRootCounts = Server.CreateObject("ADODB.Recordset")
rsListRootCounts.Open strListRootCounts, oConn1
Reply With Quote
  #2 (permalink)  
Old October 23rd, 2003, 09:41 AM
Friend of Wrox
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post

I'm not sure I understand what you are looking for. What do you mean by wanting to "join ... in the one table"? What does "join" mean in this context?

Remember that the COUNT function counts rows, and the WHERE clause selects which rows are being counted. Since your two queries are each counting the number of rows by selecting entirely different sets of rows, I don't think they can be "joined" together in any meaningful way into the same 'output' row(s)...

Jeff Mason
Custom Apps, Inc.
Reply With Quote
  #3 (permalink)  
Old October 29th, 2003, 04:50 AM
Friend of Wrox
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

I am not sure what I assume in this case is correct.

I think erin means to "sum up" those two count outputs by saying "join"

Is that so erin?

-Vijay G
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Join for two different counts on same view thenoseknows SQL Server 2000 0 January 21st, 2007 06:37 PM
Getting Counts hugh@kmcnetwork.com SQL Language 2 October 27th, 2004 04:01 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
sql & join tables & find a field in multiple table trangd Beginning PHP 2 January 29th, 2004 07:18 PM
Get Counts harpua Classic ASP Databases 3 June 10th, 2003 12:45 AM

All times are GMT -4. The time now is 07:24 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.