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 9196837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:56:16+00:00 2026-06-17T21:56:16+00:00

I need to get the maximum priority value based on the created time. My

  • 0

I need to get the maximum priority value based on the created time. My query is here,

select
  t.id, ocf1.Content Priority, ocf1.created
from
  Tickets t inner Join ObjectCustomFieldValues ocf1
  on ocf1.ObjectId=t.id
where
  ocf1.CustomField=301
  and t.queue in (27,50,49,52)
  and t.status not in ('rejected','deleted')
  and t.created between subdate(now(),interval 1500 minute) and now();

id     Priority  created
-------------------------------
27344  P4        28/01/13 09:17
27344  Incident  28/01/13 09:18
27345  P4        28/01/13 09:22
27346  P4        28/01/13 09:25
27353  P4        28/01/13 10:08
27353  Incident  28/01/13 10:09
27360  P4        28/01/13 10:38
27360  Incident  28/01/13 10:39
27365  P3        28/01/13 11:52
27376  P4        28/01/13 14:49

Example: Here I need the maximum priority value Incident for the id 27344. The same as for other ids.

  • 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-06-17T21:56:18+00:00Added an answer on June 17, 2026 at 9:56 pm
    SELECT  a.*, b.*      -- select your desired columns here
    FROM    Tickets a
            INNER JOIN ObjectCustomFieldValues b
                ON b.ObjectId = a.id
            INNER JOIN
            (
                SELECT  ObjectId, MAX(created) max_val
                FROM    ObjectCustomFieldValues
                WHERE   CustomField = 301
                GROUP   BY ObjectId
            ) c ON  b.ObjectId = c.ObjectId AND
                    b.created = c.max_val
    WHERE   b.CustomField = 301 AND
            a.queue IN (27,50,49,52) AND
            a.status NOT IN ('rejected','deleted') AND 
            a.created BETWEEN SUBDATE(NOW(), INTERVAL 1500 MINUTE) AND NOW()
    

    are your date really formatted like this: 28/01/13 09:17? and the data type is string. right? If that’s the case, you need to convert it to date time so MAX() will properly work well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the maximum value out of this code, but it's really
I am making some plugin and I need to get maximum scrollTop value of
I need to get the maximum value of a richtextbox's vertical scrollbar so that
I have a vector of doubles and I need to get the maximum value
I need to get a value which has the maximum number of occurrences in
Short: From below sql select I get the cart_id and the value of the
I need to get the minimum and maximum values in a collection of floating
I have linq request. I need get item.Title in select. how do this? var
I have two tables with a weak relation. I need get a text value
Possible Duplicate: Get maximum (more than 20) results in Google map API I need

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.