Jump to content

sql doubt


Recommended Posts

Posted
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

 

Posted
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 

Posted
8 minutes ago, 8pm said:

Use window function Lag to get previous day 

how to get backlog tickets(not only yesterday)...

Posted
Just now, nikhilboorla said:

how to get backlog tickets(not only yesterday)...

Ante enni rojulu backlog kavali?

oka range untadi kada

Posted
13 minutes ago, NiranjanGaaru said:

Manaki antha telive unte ee patiki ee hitech city lo flat koni nelaki lacha emi lu Kattukuntu undevadini

  • Confused 1
Posted
2 minutes ago, nikhilboorla said:

how to get backlog tickets(not only yesterday)...

Table structure veyyi morning choosta

Posted
Just now, Hydrockers said:

Manaki antha telive unte ee patiki ee hitech city lo flat koni nelaki lacha emi lu Kattukuntu undevadini

Ok

Posted
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'

Posted
1 hour ago, 8pm said:

Table structure veyyi morning choosta

columns mentioned in the query are the ones...no additional columns

Posted
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?

Posted
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 ? 

Posted
52 minutes ago, former said:

Is ticket table have all the ticket status events?

yes so i have filtered the table using status=pending credential

Posted

 

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)

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...