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

  • Home
  • SEARCH
  • 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 8555899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:13:47+00:00 2026-06-11T15:13:47+00:00

I want sql query to get the above result. The result is the maximum

  • 0

enter image description here

I want sql query to get the above result. The result is the maximum Id in TableA whose s_id in TableB has Stat=true i.e. 1.

The following does not do what I want:

select i.category_id,i.image_id,i.image_original,i.image_title,i.photographer 
from images i 
  inner join schedule s 
    on i.scheduleid=s.scheduleid 
    and s.status='live' 
where image_id=(select max(image_id) from images)
  • 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-11T15:13:48+00:00Added an answer on June 11, 2026 at 3:13 pm

    Use TOP to retrieve only 1 row
    Use ORDER BY to control the sorting, so you get the single row you want

    SELECT TOP(1) a.id, a.[image], a.s_id, b.stat, b.[desc]
      FROM TableA a
      JOIN TableB b on a.s_id = b.s_id
     WHERE b.stat = 1
    ORDER BY A.ID DESC
    

    An SQLFiddle showing this.

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

Sidebar

Related Questions

I want to use this SQL query to get only the records between 8
I want to write a SQL query like the following. Its syntax is not
I want to convert the following SQL Query to a SubSonic Query. SELECT [dbo].[tbl_Agency].[ParentCompanyID]
I want to translate following simple sql query into Linq to NHibernate: SELECT NewsId
I want to export my big SSMS (SQL Server Management Studio) query result (2.5m
Someone please tell me the SQL query to get the result.... Thanks! From the
I want to perform a simple sql query but cannot manage to get it
I want to create an SQL query that selects the pictures of females in
I hace sql query through this i want to calculate the records after 05:00:00
I want to parse a SQL query into an array. I could not figure

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.