Jump to content

sql doubt


nikhilboorla

Recommended Posts

I have to find Pending tickets from Previous day/Backlog(from previous days) and Converted from Pending tickets to Open for creating a report.

I have got the pending tickets using the following query.


select ticket_date,count(ticket_id) as Total_tickets_created,
sum(case when s.name = 'Pending Credential' then 1 else 0 end) as Pending_Credentials_On_hold,
( select Pending_Credentials from tickets where date >= DATEADD(day, -1, GETDATE())) ) as Pending_tickets_Backlog 
      from tickets t 
and datetime_trunc(Datetime(t.created_date,"America/Los_Angeles"),day) <> datetime_trunc(current_datetime("America/Los_Angeles"),day)

I tried above query for find Pending tickets from Previous day/Backlog but couldn't get the required output also I need to find Converted from Pending tickets to Open also using above query.Required output is below

enter image description here

 

Link to comment
Share on other sites

10 minutes ago, nikhilboorla said:
I have to find Pending tickets from Previous day/Backlog(from previous days) and Converted from Pending tickets to Open for creating a report.

I have got the pending tickets using the following query.


select ticket_date,count(ticket_id) as Total_tickets_created,
sum(case when s.name = 'Pending Credential' then 1 else 0 end) as Pending_Credentials_On_hold,
( select Pending_Credentials from tickets where date >= DATEADD(day, -1, GETDATE())) ) as Pending_tickets_Backlog 
      from tickets t 
and datetime_trunc(Datetime(t.created_date,"America/Los_Angeles"),day) <> datetime_trunc(current_datetime("America/Los_Angeles"),day)
where date(ticket_date) between '2021-04-01' and '2021-04-02'

I tried above query for find Pending tickets from Previous day/Backlog but couldn't get the required output also I need to find Converted from Pending tickets to Open also using above query.Required output is below

enter image description here

 

Use window function Lag to get previous day 

Link to comment
Share on other sites

1 hour ago, 8pm said:

Ante enni rojulu backlog kavali?

oka range untadi kada

I want from january 1st to march 31st...column should be created seperately for this as 'Pending tickets Backlog'.

April 1st Pending tickets will be stored in 'Pending Credentials'

Link to comment
Share on other sites

2 hours ago, nikhilboorla said:
I have to find Pending tickets from Previous day/Backlog(from previous days) and Converted from Pending tickets to Open for creating a report.

I have got the pending tickets using the following query.


select ticket_date,count(ticket_id) as Total_tickets_created,
sum(case when s.name = 'Pending Credential' then 1 else 0 end) as Pending_Credentials_On_hold,
( select Pending_Credentials from tickets where date >= DATEADD(day, -1, GETDATE())) ) as Pending_tickets_Backlog 
      from tickets t 
and datetime_trunc(Datetime(t.created_date,"America/Los_Angeles"),day) <> datetime_trunc(current_datetime("America/Los_Angeles"),day)
where date(ticket_date) between '2021-04-01' and '2021-04-02'

I tried above query for find Pending tickets from Previous day/Backlog but couldn't get the required output also I need to find Converted from Pending tickets to Open also using above query.Required output is below

enter image description here

 

what is the current table structure & also give some sample data?

Link to comment
Share on other sites

46 minutes ago, nikhilboorla said:

I want from january 1st to march 31st...column should be created seperately for this as 'Pending tickets Backlog'.

April 1st Pending tickets will be stored in 'Pending Credentials'

Seems Last where condition is only checking for a certain date range where as ur ‘Pending Tickets backlog’ looking for just previous day’s one ? 

Link to comment
Share on other sites

 

12 minutes ago, ZoomNaidu said:

Seems Last where condition is only checking for a certain date range where as ur ‘Pending Tickets backlog’ looking for just previous day’s one ? 

sorry..i have removed this line...Pending tickets backlog i am able to do until yesterday but i want to calculate overall tickets until yesterday(except today)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...