If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Count same column with different criteria.. only to get out last count

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-22-06, 22:41
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
Count same column with different criteria.. only to get out last count

Hi, hope some1 can help me with this.. need this urgently...thanx!

"For Each x in Action", the Action is the array that i got from another database, with 4 values... Now i'm trying to get the number of count of each value in another table...

Code:
Dim rs_eachAction
Set rs_eachAction = Server.CreateObject("ADODB.Recordset")
rs_eachAction.ActiveConnection = MM_dsprms_STRING

For Each x in Action
	sqlString = " AND Action_Taken = '" & (x) & "'"
	sqlString = "SELECT COUNT(Action_Taken) as [numAct]  FROM Security_Vulnerability WHERE (tDate BETWEEN #" & startDate & "# AND #" & endDate & "#)" & sqlString
	rs_eachAction.source = sqlString
	rs_eachAction.CursorType = 0
	rs_eachAction.CursorLocation = 2
	rs_eachAction.LockType = 1
	response.write "<p>" & rs_eachAction.source
Next

	rs_eachAction.Open()
	NumAction = rs_eachAction.getRows
	rs_eachAction.close()

For x=0 to ubound(NumAction,2)
	Response.write "<p>" & NumAction(0,x)
Next
Response.write SQL Statements:

[CODE]

SELECT COUNT(Action_Taken) as [numAct] FROM Security_Vulnerability WHERE (tDate BETWEEN #23-Feb-2006# AND #23-Feb-2006#) AND Action_Taken = 'Patch'

SELECT COUNT(Action_Taken) as [numAct] FROM Security_Vulnerability WHERE (tDate BETWEEN #23-Feb-2006# AND #23-Feb-2006#) AND Action_Taken = 'Workaround'

SELECT COUNT(Action_Taken) as [numAct] FROM Security_Vulnerability WHERE (tDate BETWEEN #23-Feb-2006# AND #23-Feb-2006#) AND Action_Taken = 'Take Note'

SELECT COUNT(Action_Taken) as [numAct] FROM Security_Vulnerability WHERE (tDate BETWEEN #23-Feb

[CODE]

I manage to search out using this 4 values, but my results for the count will only appear the last 1, which is the "No Action".

How can i get the count value of each type?
Reply With Quote
Reply

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On