473,493 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

select last update

ddtpmyra
333 Contributor
My query results has 3 rows but I only wanted to select the max date or the last update. How can i do this? I only wanted to pick the most current date which is the last record below:

Result:
1038651 2007-05-11 RMARTINEZ In-Service
1038651 2007-07-03 Equip Ret Pend Return Pending
1038651 2007-03-07 Import Returned

Query:
Expand|Select|Wrap|Line Numbers
  1.     SELECT ticket_number, MAX(ticket_status_history.addedDate) AS OrderDate, MAX(ticket_status_history.Tech_id) AS Tech_id,max(description)
  2.         FROM ticket_status_history WITH (NOLOCK)
  3.         INNER JOIN ticket_status ON ticket_status.id = ticket_status_history.current_status
  4.         WHERE 
  5.  ticket_number=1038651
  6.         GROUP BY ticket_number, description, ticket_number
May 12 '09 #1
2 2724
prabirchoudhury
162 New Member
try without GROUP BY and add ORDER BY 'ticket_status_history.addedDate` DESC LIMIT 1 that would take the last update from the top

Expand|Select|Wrap|Line Numbers
  1. SELECT ticket_number, MAX(ticket_status_history.addedDate) AS OrderDate, MAX(ticket_status_history.Tech_id) AS Tech_id,max(description) 
  2.         FROM ticket_status_history WITH (NOLOCK) 
  3.         INNER JOIN ticket_status ON ticket_status.id = ticket_status_history.current_status 
  4.         WHERE  
  5.  ticket_number=1038651 ORDER BY ticket_status_history.addedDate DESC LIMIT 1
May 12 '09 #2
charles07
45 New Member
i used this,worked for me

Expand|Select|Wrap|Line Numbers
  1. select max(timestamp),method,id from tables where 1 group by method,id order by timestamp desc 
May 4 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4546
by: Marco | last post by:
Hi there ive trying to make a game based on php and currently ive some problems with this part of the script, i've tryed to fix it alone with out success... This is the script <?php...
17
4969
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
2
9905
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
4
4062
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement...
29
27508
by: pb648174 | last post by:
I have the following basic statements being executed: Create a temp table, #TempPaging Insert Into #TempPaging (Col1, Col2) Select Col1, Col2 From SomeOtherTable Order By Col2, Col1 Select...
19
8339
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
16
2716
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
2
2734
by: woodey2002 | last post by:
Hi Guys and thanks for your time. I have a search form for my database that allows users to select multiple criteria from multi select list boxes. I successfully integrated a multi select...
6
4653
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option...
3
2186
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.