ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not one of the good ones at this so I could really need som help.
I have a table that I use as a log for a system.
In this log I have the columns: id, fname, lname, number, status and date.
Date is auto generated with date and time.
The column "id" is not unique.
The table is full of data and some id's have multiple status.
Short simplified example below:
id status date
5 return 20110101
5 return 20110102
5 no answer 20110103
5 return 20110104
5 no answer 20110105
6 return 20110101
6 return 20110102
6 no answer 20110103
6 return 20110104
6 no answer 20110105
6 return 20110106
Now I need to search the entire table for every "id" where the latest date for each "id" resulted in a "no answer".
From my short table example above I must get the results:
id status date
5 no answer 20110105
6 no answer 20110105
Yes, I understand and promote that, not only with SQL. I refrained before giving whole query, this was only a hint, as I stated that your answer "SELECT id" was too general.
Ah, good job. I thought he was going to use a where clause, but group by and max worked too. There is more then one way to write the sql query he wants. The smaller the query, the better.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.