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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:23:56+00:00 2026-06-18T11:23:56+00:00

If an image is marked as active and a person clicks on the link

  • 0

If an image is marked as active and a person clicks on the link they should be taken to the active image otherwise they should be taken to the (MAX) most recent image uploaded. My first select works but not entirely.

Here’s my select:

    select
    b.image_id, b.active, c.id as event_id
from event.dbo.lite() a
left outer join event.dbo.dia_tracker b on a.code = b.patient_id 
    and image_id = (select max(image_id) from event.dbo.dia_tracker where patient_id = {$patient->hex})
left outer join event.dbo.ev c on a.code = c.patient_id and c.task_id in ('WR','RC') and c.status<>0
where a.code = {$patient->hex}

Here’s my new select that I need a bit of help with.

select 
    image_id, 
    active,
    case when active <>1 than image_id = (select max(image_id) from event.dbo.dia_tracker where patient_id = 'DSMA')
from event.dbo.dia_tracker

where active = '1' and image_id = (select max(image_id) from event.dbo.dia_tracker where patient_id = 'DSMA')

it’s a bit of a mess atm. I was thinking I could use isnull to accomplish more in less lines of code.

update:

select 
    *,
    ISNULL(active,image_id) as  image
from event.dbo.dia_tracker

    where active = '1' and image_id = (select max(image_id) from event.dbo.dia_tracker where patient_id = 'DSMA')

Still need help.

  • 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-18T11:23:58+00:00Added an answer on June 18, 2026 at 11:23 am

    It would be much easier if you would post all relevant DDL and sample data, but you can try something like this to get your image_id

    SELECT COALESCE(
      (SELECT image_id FROM dia_tracker WHERE patient_id = 'DSMA' AND active=1), 
      (SELECT MAX(image_id) FROM dia_tracker WHERE patient_id = 'DSMA')
    ) AS image_id
    

    And if it (image_id) uniquely identifies the row you’re looking for you can try

    SELECT * FROM dia_tracker
    WHERE image_id = (SELECT COALESCE(
      (SELECT image_id FROM dia_tracker WHERE patient_id = 'DSMA' AND active=1), 
      (SELECT MAX(image_id) FROM dia_tracker WHERE patient_id = 'DSMA')
    ) AS image_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert image into HTML sections ( see image below marked as
I have an image of licence plate and the numbers is marked with black
On images below there is some specific pattern. Its best visible on first image.
Image converted to RGB grayscale. Next, Grayscale-image is translated into an array, which are
Image Dummy = Image.FromFile(image.png); Dummy.Save(image.bmp, ImageFormat.Bmp); what the question says i have these using
image naturalWidth return zero... that's it, why ? var newimage = new Image(); newimage.src
Image describing the problem http://img215.imageshack.us/img215/3725/20100314235127schedule2.jpg I hope the image above can explain what I
Image size is not the problem here, because my image is 800 Kb. My
Image on the left what I want, on the right what I keep getting.
picturebox1.image = image.fromfile(c:/anim.gif) after i import the animation, i want to Stop the animation

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.