Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:13:29+00:00 2026-05-24T14:13:29+00:00

I have to write an SQL statement which contain a field that contain two

  • 0

I have to write an SQL statement which contain a field that contain two different values consecutively but in the way I have wrote it, it return always null because it is interpreted as having the two value in the same time!

My conditions should be : (ci.field = ‘Group’ and ci.oldString = ‘Triage’ ) and (ci.field=’assignee’ and ci.newString is not NULL)

That means calculate time between: when the issue is assigned to group named Triage and when the issue is assigned to a person.

How can I fix it?

My SQL statement:

select TIMEDIFF(a.created,b.created) 
from
(select g.created, g.issueid as groupid1 
    from   changegroup g
    join   changeitem ci on (ci.groupid = g.id)
    join   jiraissue ji on (ji.id = g.issueid)
    join   project p on (p.id = ji.project)
    join   priority pr on (pr.id = ji.priority)
    where  ci.field = 'Group'
    and  ci.oldString = 'Triage' 
    and  ci.field='assignee'
    and ci.newString is not NULL
    and  p.pname = 'Test'
    and pr.pname='P1'
    and  ji.created between '2011-08-11 14:01:00' and  '2011-08-12 14:11:00'
) a 
left join (
    select ji.created, ji.id as groupid2 
    from   jiraissue ji
    join   changegroup g on (g.issueid = ji.id)
    join   project p on (p.id = ji.project)
    where  p.pname = 'Test'
      and  ji.created between '2011-08-11 14:01:00' and '2011-08-12 14:11:00' 
) b ON (a.groupid1 = b.groupid2);

This is the table from which I should retrieve data

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:13:30+00:00Added an answer on May 24, 2026 at 2:13 pm

    See my comment about the quality of your question but a hint at how to solve this goes like (assuming you can make sure this doesn’t create 1-n joins)

    select groupid_orsomething_else, TIMEDIFF(a.created, b.created) 
    from yourtable
    left join 
     (select groupid_orsomething_else, created 
      from yourtable 
      where field = 'Group' and oldstring is 'Triage'
     ) a 
    on a.groupid_orsomething_else = yourtable.groupid_orsomething_else
    left join 
     (select groupid_orsomething_else, created 
      from yourtable 
      where field = 'assignee' and oldstring is null) b 
    on b.groupid_orsomething_else = yourtable.groupid_orsomething_else
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL statement that displays the following values, but the number of
I have a perplexing SQL select statement (ugly) that I'm trying to write in
I'm looking for a way to write an SQL statement in C# targeting different
I have to write a component that re-creates SQL Server tables (structure and data)
I have been asked in an interview to write a SQL query which fetches
We have some SQL server reporting services reports. I didn't write then but I
I have a SQL statement in which I do this ... group by date
I currently have a prepared statement in Java which uses the following SQL statement
I have an sql query that requires repeating the same SELECT statement a number
Is there a way to write SQL Server Stored Procedure which to be strongly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.