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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:30:12+00:00 2026-06-04T11:30:12+00:00

I have a db table like: —————————- id name cat ============================ 1 20.gif logo

  • 0

I have a db table like:

----------------------------
id  name        cat
============================
1   20.gif      logo
2   21.gif      logo
3   22.gif      logo
4   15.gif      web
5   16.gif      web
6   17.gif      web
7   23.gif      logo
8   18.gif      web
9   19.gif      web

and I want to fetch highest (latest inserted record for each cat) some thing like:

----------------------------
id  name        cat
============================
7   23.gif      logo
9   19.gif      web

for this I queried:

SELECT id, name, cat FROM portfolio GROUP BY cat ORDER BY name DESC

but because name field is an string so I cant apply ORDER BY on name.

any idea..?

  • 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-06-04T11:30:13+00:00Added an answer on June 4, 2026 at 11:30 am

    Yes I found the solution :

    select id, name, cat from (select * from portfolio ORDER BY id DESC) AS x GROUP BY cat
    

    I got help from Retrieving the last record in each group

    Thanks to Stackoverflow which really make developers life easy 🙂

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

Sidebar

Related Questions

I have a table like the following table: UserID Num1 Num2 Code Name Cat
I have a table like this: name code group john 12 smith 15 how
i have a table like this one: -------------------------------- id | name -------------------------------- 1 |
I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I have table like below id, employee_no, survey_no, name 1 test 1 test_name 2
I have a table like this C1 C2 1 0 1 1 i want
I have table like this ------------------------------------------------------------------- id | title | image | name |
I have a table like this: ID | name ================================= 1 | apple 1
I have a table like the one below. It is a record of daily
I have a table like this.. S.No Name created_date 1 N1 2011-01-08 2 N2

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.