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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:44:45+00:00 2026-05-16T12:44:45+00:00

I have a table that has notes in it. It has a bunch of

  • 0

I have a table that has notes in it. It has a bunch of notes that automatically do different thing according to what someone does in the system.

When an order is assined it makes a note that says “Order was assigned to ‘name'”
When an order is re-assigned it makes a note that says “Order was re-assigned to ‘name'”

When an order is assigned initially it throws the “Order was assigned to ‘name'” statement into notes.

After that anytime the order is assigned again it throws the order was re-assigned.

The problem I have is that if the order is put into the system by the same person that assigns it to themselves it skips right to the reassigned note without even saying the order was assigned to.

Right now in my WHEN condition I have the following:

WHEN LEFT(n.Text,21) = 'Order was assigned to'

This basically returns only the name where the order was assinged the first time. Since if someone assigns an order to themself it skips this note, I need a statement that does this but if there is not ‘Order was assigned to’ I need to return the first order was re-assigned to note. These notes also have an audit insert timestamp field in the same table. An order can be re-assigned many times but I only want the first one if there is no Order was assigned to note.

How would I do this?

I know this is terrible application design but I didn’t design it and I can’t change it. I just need to know how to write the SQL.

THANKS!!!

  • 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-16T12:44:46+00:00Added an answer on May 16, 2026 at 12:44 pm

    You can take your current query, and add a UNION query with the same code and a slightly different where clause. The LEFT() would look for the re-assigned note, and you would add a NOT EXISTS clause to exclude orders with the proper note from the first query.

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

Sidebar

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.