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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:02:44+00:00 2026-06-16T00:02:44+00:00

i need some help with this SQL Join.. I have a table sales ,

  • 0

i need some help with this SQL Join..

I have a table “sales” , looking like this

date        idpart
1311316400   5
1321316400   6
1341216400   7
1351516400   8

and a table “parts” looking like this

idpart   name    inprice  outprice
 5        a        10       40
 6        b        20       55
 7        c        20       55 
 8        d        20       55

Now i want to find the sum of all partsales between a user given date A and date B , by doing something like this:

SELECT idpart, SUM( inprice ) 
FROM parts, sales
WHERE parts.idpart = sales.idpart
GROUP BY idpart
LIMIT 0 , 30

But by doing this i get the value of inprice for each of the time a part is in sales table.
I want the total for the entire period between A and B.
I dont know where i should insert the :

WHERE date BETWEEN A AND B

any tips for a SQL beginner ?

  • 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-16T00:02:45+00:00Added an answer on June 16, 2026 at 12:02 am

    If I got your question right, then you can just combine your conditions using the keyword AND:

    SELECT SUM( inprice ) 
    FROM parts, sales
    WHERE parts.idpart = sales.idpart
    AND sales.date BETWEEN A AND B
    LIMIT 0 , 30
    

    For better readability always use the “new” JOIN-syntax. Once your queries become more complex, this makes it a lot easier to understand your queries:

    SELECT SUM( parts.inprice ) 
    FROM sales
    JOIN parts ON ( parts.idpart = sales.idpart )
    WHERE sales.date BETWEEN a AND b
    LIMIT 0, 30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help to build SQL Query. I have table having data like:
i need some help with a sql query. I have a table called 'table1'
I could need some help with a SQL statement. So I have the table
i need some help with this sql query heres my mysql table structure: DOMAINS
I really need some help with this as I have been trying to fix
Need some help to solve this. I have a gridview and inside the gridview
I need some help to get this right, please. I have created an iPad
Im trying to convert a SQL join to LINQ. I need some help in
i use a sql query like this to get some results i need: SELECT
I need help designing a SQL table. Suppose I have cardnumber , cardtype ,

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.