473,244 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

select last update

333 100+
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:

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

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 2715
162 100+
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
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

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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.