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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:12:15+00:00 2026-05-13T10:12:15+00:00

I have a very specific query that is acting up and I could use

  • 0

I have a very specific query that is acting up and I could use any help at all with debugging it.

There are 4 tables involved in this query.

Transaction_Type
Transaction_ID (primary)
Transaction_amount
Transaction_Type

Transaction
Transaction_ID (primary)
Timestamp

Purchase
Transaction_ID
Item_ID

Item
Item_ID
Client_ID

Lets say there is a transaction in which someone pays $20 in cash and $0 in credit it inserts two rows into the table.

//row 1
Transaction_ID: 1
Transaction_amount: 20.00
Transaction_type: cash
//row 2
Transaction_ID: 1
Transaction_amount: 0.00
Transaction_type: credit

here is the specific query:

SELECT 
 tt.Transaction_Amount, tt.Transaction_ID
FROM 
 ItemTracker_dbo.Transaction_Type tt
JOIN 
 ItemTracker_dbo.Transaction t
   ON
 tt.Transaction_ID = t.Transaction_ID
JOIN
 ItemTracker_dbo.Purchase p
   ON
 p.Transaction_ID = tt.Transaction_ID
JOIN
 ItemTracker_dbo.Item i
   ON
 i.Item_ID = p.Item_ID
WHERE
 t.TimeStamp >= "2010-01-06 00:00:00" AND t.TimeStamp <= "2010-01-06 23:59:59"
   AND
 tt.Transaction_Format IN ('cash', 'credit')
   AND
 i.Client_ID = 3

when I execute this query, it returns 4 rows for a specific transaction. (it should be 2)

When I remove ALL where clauses and insert WHERE tt.Transaction_ID = problematicID it only returns two.

EDIT:::::
still repeats upon changing date range
The kicker:

When I change the initial daterange it only returns two rows for that specific transaction_id.
::::

Is it the way I use join? that’s all I can think of…

EDIT: This is the problem

in purchase – two sepparate purchase_ID’s can have the same transaction_ID (purhcase_ID breaks down specific item sales).

There are duplicate Transaction_ID rows in purchase_ID

  • 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-13T10:12:16+00:00Added an answer on May 13, 2026 at 10:12 am

    We need to see all the data in all the tables to be able to know where the problem is. However, because the joins are the problem it is because one of your tables has two rows when you think it has only one.

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

Sidebar

Related Questions

I have geographic data that was loaded into the geography datatype. For very specific
I could try to post and explain the exact query I'm trying to run,
I'm having a little bit of a dilemma. I have a very basic class
We have an application that has been deployed to 50+ websites. Across these sites
We have an application built on top of SQL server 2005 that we have
This is very specific, and a bit difficult to explain, and quite likely impossible,
Using SQL Server 2005, I have a table where certain events are being logged,
NOTE: the original question is moot but scan to the bottom for something relevant.
Background In my current project - a server product with no GUI front-end, I'm

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.