Jump to content

Reporting how to SQL - LIMIT BY 1 ?


billster

Recommended Posts

Hello,

I am running a report and I want to do a LIMIT BY 1 to get the latest record in the table as it is pulling through every record there is (per Request ID). I want to have only the record which is circled in blue.

image.thumb.png.a37ea58ebfa6a6322d605bc8cc7cc33d.png

 

here is how I am getting the report...

image.thumb.png.98438fa878b8222475787269520157b4.png

 

image.thumb.png.b39677ee080d138665cbcaae1fe9a76b.png

image.thumb.png.582017b84eb324c9834f7ca62ef33e30.png

image.thumb.png.876e87495fc7792e2efc9f5d7f3cfe83.png

Link to comment
Share on other sites

(select h_pk_updateid as test from h_itsm_requesthistupdates
WHERE h_itsm_requests.h_pk_reference = h_itsm_requesthistupdates.h_fk_reference
Order by h_pk_updateid desc
Limit 1)

 

image.png

  • Thanks 1
Link to comment
Share on other sites

32 minutes ago, Jim said:
(select h_pk_updateid as test from h_itsm_requesthistupdates
WHERE h_itsm_requests.h_pk_reference = h_itsm_requesthistupdates.h_fk_reference
Order by h_pk_updateid desc
Limit 1)

 

image.png

perfect, works a treat :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...