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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:31:18+00:00 2026-06-09T11:31:18+00:00

I have a query that will check a table for a voided invoice, and

  • 0

I have a query that will check a table for a voided invoice, and then check the same table
to see if the voided invoice was re-tendered. What i’d like to know… is, is there a way
to add a column to see If a voided invoice was NOT re-tendered, and list that as “N” in the column..

Here is my Current Query:

SELECT        t1.Store_Number, t1.Invoice_Number, t1.Invoice_Date, t1.Vehicle_Tag, t1.Void_Reason, t1.Void_Employee_Tax_Payer_Id, t1.Invoice_Total, t1.Void_Flag, 
                         t2.Invoice_Number AS Expr1, t2.Vehicle_Tag AS Expr2, t2.Invoice_Total AS Expr3
FROM            Invoice_Tb AS t1 INNER JOIN
                         Invoice_Tb AS t2 ON t1.Vehicle_Tag = t2.Vehicle_Tag
WHERE        (t1.Void_Flag = 'y') AND (t1.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102)) AND 
                         (t2.Void_Flag = 'n') AND (t2.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102))

Here is my current Output:

Store Number    Invoice Number  Date    Plate Number    Void Reason Employee    Invoice Amount Voided   New Invoice Number  Plate Number    New Invoice Amount  Re-Tendered
1568    3257714 8/1/2012 0:00   BBY1234 WRONG PRICE ENTERED 89556532    21.39   3257714 BBY1234 26.74   Y

An Example of what I would like: Lets say Invoice #123 was voided, and never re-tendered… I would want to
show the above and add a column header “re-tendered” and list “n” where an invoice was not
re-tendered. The output would be similar to this:

Store Number    Invoice Number  Date    Plate Number    Void Reason Employee    Invoice Amount Voided   New Invoice Number  Plate Number    New Invoice Amount  Re-Tendered
1568    3257714 8/1/2012 0:00   BBY1234 WRONG PRICE ENTERED 89556532    21.39   3257714 BBY1234 26.74   Y
1552    123 8/1/2012 0:00   Dwb0534 Wrong Plate number  73215654    15.95               N
  • 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-09T11:31:20+00:00Added an answer on June 9, 2026 at 11:31 am

    you need a left join

    SELECT        t1.Store_Number, t1.Invoice_Number, t1.Invoice_Date, t1.Vehicle_Tag, t1.Void_Reason, t1.Void_Employee_Tax_Payer_Id, t1.Invoice_Total, t1.Void_Flag, 
                             t2.Invoice_Number AS Expr1, t2.Vehicle_Tag AS Expr2, t2.Invoice_Total AS Expr3, case when t2.Vehicle_Tag is null then 'n' else 'y' end as retendered
    FROM            Invoice_Tb AS t1 LEFT JOIN
                             Invoice_Tb AS t2 ON t1.Vehicle_Tag = t2.Vehicle_Tag And
                             (t2.Void_Flag = 'n') AND (t2.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102))
    WHERE        (t1.Void_Flag = 'y') AND (t1.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102))  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP code, that will run a Select query to check if
I have a page a query that will set a table to 0 or
Im trying to write an SQL query that will check in the table ‘persons’
I have a query that will be put into a procedure, and it will
I have a problem with an sql query that will not work if I
I want to add an extra field to my query that will have the
I have a simple query: $query = new WP_Query('showposts=5'); that will obviously display 5
I have a query that successfully grabs the unique products from my products table
I'm trying to create a query on SQL server 2005 that will check if
I have stored proc that will tell us if there is any new checks

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.