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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:48:37+00:00 2026-05-13T01:48:37+00:00

Say I want to do this with SQL (Sybase): Find all fields of the

  • 0

Say I want to do this with SQL (Sybase): Find all fields of the record with the latest timestamp.

One way to write that is like this:

select * from data where timestamp = (select max(timestamp) from data)

This is a bit silly because it causes two queries – first to find the max timestamp, and then to find all the data for that timestamp (assume it’s unique, and yes – i do have an index on timestamp). More so it just seems unnecessary because max() has already found the row that I am interested in so looking for it again is wasteful.

Is there a way to directly access fields of the row that max() returns?

Edit: All answers I see are basically clever hacks – I was looking for a syntactic way of doing something like max(field1).field2 to access field2 of the row with max field1

  • 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-13T01:48:37+00:00Added an answer on May 13, 2026 at 1:48 am

    No, using an aggregate means that you are automatically grouping, so there isn’t a single row to get data from even if the group happens to contain a single row.

    You can order by the field and get the first row:

    set rowcount 1
    select * from data order by timestamp desc
    

    (Note that you shouldn’t use select *, but rather specify the fields that you want from the query. That makes the query less sensetive to changes in the database layout.)

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

Sidebar

Related Questions

I want to do this so that I can say something like, svn mv
At first I want to say: I couldn't find a support forum for this
I want write this sql select statment in mysql v 3.23 select * from
First of all I want to show how I made this in SQL: Both
I've been struggling with this one SQL query requirement today that I was wondering
let say I want to do this: var dashboard = {}; var page =
let's say Expr = 1+2. and I want this Expr in parenthesis, what should
Say you want to filter elements out of a List. Running this code triggers
Let's say I want to do something like this void my_printf(char *fmt,...) { char
Let's say I want a method which will be called like this: tiger =

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.