Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting procentiage in a SQL 1

Status
Not open for further replies.

Larshg

Programmer
Mar 1, 2001
187
DK
Hi

I have this SQL



AntalOfAlarm_ID Severity Nodename Primary_Responsible
242 HIGH SPLINTER Billing Drift
230 HIGH CRM1 Billing Drift
217 HIGH DELFI1 Billing Drift


I would like there to be another colum that shows how many of the rows
 
Code:
SELECT

AntalOfAlarm_ID, Severity, Nodename,Primary_Responsible, Count(*) AS Ct

FROM yourtable

GROUP BY

AntalOfAlarm_ID, Severity, Nodename,Primary_Responsible
 
Sorry I submittede it by mistake - here is the full version

I have this SQL
SELECT Count(ALARMLIST_komplet.Alarm_ID) AS AntalOfAlarm_ID, IIf(InStr(",A3,B2,B3,C1,C2,C3,","," & [NodeBusinessPrio] & ",")>0,"MEDIUM","HIGH") AS Severity, ALARMLIST_komplet.Nodename, ALARMLIST_komplet.Primary_Responsible
FROM ALARMLIST_komplet
WHERE (((Format([ALARMLIST_komplet].[Create_Date],"yyyymm"))="200411"))
GROUP BY IIf(InStr(",A3,B2,B3,C1,C2,C3,","," & [NodeBusinessPrio] & ",")>0,"MEDIUM","HIGH"), ALARMLIST_komplet.Nodename, ALARMLIST_komplet.Primary_Responsible, Format([ALARMLIST_komplet].[Create_Date],"yyyymm")
ORDER BY IIf(InStr(",A3,B2,B3,C1,C2,C3,","," & [NodeBusinessPrio] & ",")>0,"MEDIUM","HIGH"), Count(ALARMLIST_komplet.Alarm_ID) DESC;


Thats result in a output like this

AntalOfAlarm_ID Severity Nodename Primary_Responsible
242 HIGH SPLINTER Billing Drift
230 HIGH CRM1 Billing Drift
217 HIGH DELFI1 Billing Drift


I would like there to be another colum that shows how many of the rows it selects, in Talked_to_DC_Nord_Person_ has like 'XX_*'

so the output should be something like this
AntalOfAlarm_ID Severity Nodename Primary_Responsible %_that_has_XX
242 HIGH SPLINTER Billing Drift 14
230 HIGH CRM1 Billing Drift 15
217 HIGH DELFI1 Billing Drift 30


I basicly want the same output just counting how many of them has XX in Talked_to_DC_Nord_Person_

Hope someone can help

/Larshg
 
A starting point:
SELECT Count(Alarm_ID) AS AntalOfAlarm_ID, IIf(InStr(",A3,B2,B3,C1,C2,C3,","," & [NodeBusinessPrio] & ",")>0,"MEDIUM","HIGH") AS Severity, Nodename, Primary_Responsible
, Sum(IIf(Talked_to_DC_Nord_Person_ has Like 'XX_*',1,0)) As CountOfXX
FROM ALARMLIST_komplet
WHERE Format([Create_Date],"yyyymm")="200411"
GROUP BY IIf(InStr(",A3,B2,B3,C1,C2,C3,","," & [NodeBusinessPrio] & ",")>0,"MEDIUM","HIGH"), Nodename, Primary_Responsible
ORDER BY 2, 1 DESC;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top