sql 旧版McAfee Helpdesk SQL语句

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 旧版McAfee Helpdesk SQL语句相关的知识,希望对你有一定的参考价值。

SELECT     *
FROM         activity_action_note
WHERE      action_dt =(SELECT     MAX(action_dt)
FROM         activity_action_note
WHERE     (activity_num = '8288'))



/* Open calls ordered by date logged */
Select A.activity_num, RTrim(C.name), RTrim(A.status_id), A.act_dt
From Activity A, Client C
Where A.client_id = C.client_id
And A.closed = 0
Order By A.act_dt
/* Open calls ordered by customer */
Select A.activity_num, RTrim(C.name), RTrim(A.status_id), A.act_dt
From Activity A, Client C
Where A.client_id = C.client_id
And A.closed = 0
Order By C.Name
/* Open calls ordered by customer */
Select RTrim(C.name), A.activity_num, RTrim(A.status_id), A.act_dt, A.priority_id
From Activity A, Client C
Where A.client_id = C.client_id
And A.closed = 0
Order By A.priority_id
/* Number of open calls per customer */
Select RTrim(C.Name), Count(*)
From Activity A, Client C
Where A.client_id = C.client_id
And A.closed = 0
Group By C.Name
Order By Count(*) Desc
use ServiceDesk
go

select 
count (*)
from activity
where client_id = '12' and
act_dt >= 'Mar 31 2002'

select
activity_num as 'HD Ref',
act_dt as 'Log Date',
status_id 'Status'
from activity
where client_id = '12' and
act_dt >= 'Mar 31 2002'
/* Peter Lyon-Marrian - 1st April 2003
   This query will search for all open helpdesk calls and calculate how long each one has been 
   open for in days. It will also list the client name and the current call status.
*/
Use Servicedesk
select activity.activity_num as 'Helpdesk Ref:', activity.act_dt as 'Date Call Opened', DATEDIFF(day, activity.act_dt, getdate()) AS 'No Of Days Open', client.name as 'Client Name', activity.status_ID as Status
from activity inner join client
on activity.client_ID = client.client_ID
where closed = '0' 
order by status, act_dt asc
/* Peter Lyon-Marrian - 1st April 2003
   This query will search for all open helpdesk calls and calculate how long each one has been 
   open for in days. It will also list the client name and the current call status.
*/
Use Servicedesk
select activity.activity_num as 'Helpdesk Ref:', activity.act_dt as 'Date Call Opened', DATEDIFF(day, activity.act_dt, getdate()) AS 'No Of Days Open', client.name as 'Client Name', activity.status_ID as Status
from activity inner join client
on activity.client_ID = client.client_ID
where closed = '0' 
and client.client_id = 'XXX'
order by status, act_dt asc
use servicedesk

select s.activity_num,s.act_dt,note 
from activity s,activity_action_note a 
where s.activity_num = a.activity_num and s.act_dt = a.action_dt and status_id = 'ONHOLD'
order by s.activity_num
use ServiceDesk
go

select
DATENAME(Weekday, action_dt) as 'Day of Week',
DAY(action_dt) as 'Day',
DATENAME(month,(action_dt)) as 'Month',
YEAR(action_dt) as 'Year',
convert(int,DATENAME(Hour,action_dt)) as 'Hour',
count(distinct(activity_num)) as 'No of Calls',
count(activity_num) as 'Entries'
from activity_action_note
where datediff(day,action_dt,getdate())<=7 and note is not null 
group by DATENAME(month,(action_dt)),
DATENAME(Weekday, action_dt),
DAY(action_dt),
convert(int,DATENAME(Hour,action_dt)),
YEAR(action_dt),
datediff(day,action_dt,getdate())
order by datediff(day,action_dt,getdate()),convert(int,DATENAME(Hour,action_dt)) desc
go
use ServiceDesk
go

select
DATENAME(Weekday, action_dt) as 'Day of Week',
DAY(action_dt) as 'Day',
DATENAME(month,(action_dt)) as 'Month',
YEAR(action_dt) as 'Year',
count(distinct(activity_num)) as 'No of Calls',
count(activity_num) as 'Entries'
from activity_action_note
where datediff(day,action_dt,getdate())<=365 and note is not null
group by DATENAME(month,(action_dt)),
DATENAME(Weekday, action_dt),
DAY(action_dt),
YEAR(action_dt),
datediff(day,action_dt,getdate())
order by datediff(day,action_dt,getdate())
go
/* Query to report all note contacts added to helpdesk today.
*/
use ServiceDesk
go
select resource_id, count(activity_num) as 'No of log entries', count(distinct(activity_num))as 'No of calls'  from activity_action_note
where datediff(day,action_dt,getdate())=0 and note is not null group by resource_id order by count(distinct(activity_num)) DESC
go
select 'Total No of calls = ', count(distinct(activity_num)) from activity_action_note
where datediff(day,action_dt,getdate())=0 and note is not null order by count(distinct(activity_num)) DESC
go
select activity_action_note.activity_num, datepart(hour,action_dt) as 'H' ,datepart(minute,action_dt) as 'M',resource_id,activity_action_id,note
from activity_action_note,activity 
where  activity.activity_num=activity_action_note.activity_num and datediff(day,action_dt,getdate())=0 and note is not null order by resource_id,action_dt
/* Query to report all note contacts added to helpdesk today.
*/
use ServiceDesk
go
select resource_id, 'No of calls = ', count(distinct(activity_num)) from activity_action_note
where datediff(day,action_dt,getdate())=0 and note is not null group by resource_id order by count(distinct(activity_num)) DESC
go
select 'Total No of calls = ', count(distinct(activity_num)) from activity_action_note
where datediff(day,action_dt,getdate())=0 and note is not null order by count(distinct(activity_num)) DESC
go
select activity_action_note.activity_num,status_id, action_dt,resource_id,activity_action_id,note
from activity_action_note,activity 
where  activity.activity_num=activity_action_note.activity_num and datediff(day,action_dt,getdate())=0 and note is not null order by status_id,resource_id,action_dt
/* Julian Croker - 29th June 2000
   This query will indicate the Activity Numbers that contain a particular word in the Activity Note.
   Substitute the word you want to search for 'XXXX'
   To return the first 255 characters of the Note text, alter the query to select activity_num,note
select activity_num,note from activity_action_note where note <> NULL and note LIKE '%XXXX%' order by activity_num
*/
Use Servicedesk
select distinct(activity_num) 
from activity_action_note 
where note is not NULL and note LIKE '%XXXX%' 
order by activity_num
/* Query to report all note contacts added to helpdesk in the last 24 hours.
*/
select 'No of notes= ', count(*) from activity_action_note
where datediff(day,action_dt,getdate())<=1 and note is not null
go

select activity_action_note.activity_num,status_id, action_dt,resource_id,activity_action_id,note
from activity_action_note,activity 
where  activity.activity_num=activity_action_note.activity_num and datediff(day,action_dt,getdate())<=1 and note is not null order by resource_id,action_dt
/* Steve Hare 11th Feb 2003
   This query will return Open Calls Only!!!!
   This query will indicate the Activity Numbers that contain a particular word in the Activity Note.
   Substitute the word you want to search for 'XXXX'
   
*/


select distinct activity_num, status_id from dbo.activity where status_id <> 'CLOSED'

AND activity_num IN

(select activity_num from activity_action_note where note is not NULL and note LIKE '%XXXX%')


/* Julian Croker - 6th July 2001
   This query will indicate the Activity Numbers that contain a particular word in the Activity Note.
   Substitute the word you want to search for 'XXXX' and substitute the HD Client ID for YYY
*/
use SERVICEDESK
select status_id,activity_action_note.activity_num,note
from activity,activity_action_note
where activity.activity_num = activity_action_note.activity_num
 and note is not NULL
 and note LIKE '%XXXX%'
 and client_id = 'YYY'
order by activity_action_note.activity_num
/* Julian Croker - 6th July 2001
   This query will indicate the Activity Numbers that contain a particular word in the Activity Note.
   Substitute the word you want to search for 'XXXX' and substitute the HD Client ID for YYY
*/
use servicedesk /*modified by E-man 26/07/2004*/
select status_id,activity_action_note.activity_num,note
from activity,activity_action_note
where activity.activity_num = activity_action_note.activity_num
 and note is not NULL
 and note LIKE '%mssoap%'
 and client_id = '33'
order by activity_action_note.activity_num
/* Julian Croker - 6th July 2001
   This query will indicate the Activity Numbers that contain a particular word in the Activity Note.
   Substitute the word you want to search for 'XXXX' and substitute the HD Client ID for YYY
*/
select status_id,activity_action_note.activity_num,note
from activity,activity_action_note
where activity.activity_num = activity_action_note.activity_num
 and note is not NULL
 and note LIKE '%XXXX%'
 and client_id = 'YYY'
order by activity_action_note.activity_num
/* Peter Lyon-Marrian - 1st April 2003
   This query will search for all open helpdesk calls and calculate how long each one has been 
   open for in days. It will also list the client name and the current call status.
*/
Use Servicedesk
/* select activity.activity_num as 'Helpdesk Ref:', activity.act_dt as 'Date Call Opened', DATEDIFF(day, activity.act_dt, getdate()) AS 'No Of Days Open', client.name as 'Client Name', activity.status_ID as Status */
select client.name as 'Client Name',count(activity.activity_num) as 'No of Calls'
from activity inner join client
on activity.client_ID = client.client_ID
where closed = '0'
/* group by client.name with rollup */
group by client.name with rollup


以上是关于sql 旧版McAfee Helpdesk SQL语句的主要内容,如果未能解决你的问题,请参考以下文章

将旧版 SQL 查询转换为标准 SQL

旧版 sql 和标准 sql 之间的 BigQuery 表分区差异

如何将旧版 SQL BigQuery 转换为标准 SQL?

sql 旧版SOJ SQL语句

sql 旧版混合SQL语句

无法使用 R dplyr 在旧版 SQL 查询中引用 SQL 视图