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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:37:25+00:00 2026-06-18T06:37:25+00:00

i would like to ask a question here… let me explain it… here i

  • 0

i would like to ask a question here… let me explain it…
here i have 3 table,
1. transaction_table
2. transaction_detail
3. item

Nah, my problem here is i want to know the item sales of this month (2013-01) for an example, here’s my table structure…

1 Transaction Table

--------------------------
idTransaction | date       | idUser | idCustomer  | total   | NOSC
--------------------------------------------------------------------
1             | 2013-01-01 | 3      | 4           | 500000  | 1CO
2             | 2013-01-01 | 3      | 5           | 450000  | 2CO
3             | 2013-01-01 | 3      | 6           | 250000  | 3CO

2 transaction_detail

-----------------------------------------------------------------
idTransaction | idItem | qty | price
----------------------------------------
1             | 1      | 2   | 250000
2             | 2      | 1   | 250000
2             | 3      | 1   | 200000
3             | 1      | 1   | 250000

3 Item Table

idItem | Name Item
---------------------------------------
1      | glass
2      | Medicine A
3      | Medicine B

4 Customer

 idCustomer | Name Customer
    --------------------------------------
    4             | Abuh
    5             | Abeh
    6             | ABooh

So based on these table i would like to get data like this….

Name Item | Nosc | Customer | Sold Quantity | @ Price | Total
---------------------------------------------
Glass     | 1CO  | Abuh     |2              | 250000  | 500000
Glass     | 3CO  | ABooh    |1              | 250000  | 250000
Medicine A| 2CO  | Abeh     |1              | 250000  | 250000
Medicine B| 2CO  | Abeh     |1              | 200000  | 200000

Anyone can help me??

  • 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-18T06:37:26+00:00Added an answer on June 18, 2026 at 6:37 am
    SELECT  b.`name Item`,
            a.qty `Sold Quantity`,
            a.price `@ price`,
            (a.qty * a.price) Total
    FROM    transaction_detail a    
            INNER JOIN Item b
                ON a.idItem = b.idItem
    
    • SQLFiddle Demo

    The query above is based on the records and result given on the example. Follow-up question(s): is there any possibility that a certain Item can be sold with different price? If so, how do you calculate it?

    UPDATE 1

    SELECT  b.`name Item`,
            SUM(a.qty) `Sold Quantity`,
            a.price `@ price`,
            (SUM(a.qty) * a.price) Total,
            c.Date
    FROM    transaction_detail a    
            INNER JOIN Item b
                ON a.idItem = b.idItem
            INNER JOIN `transaction` c
                ON a.idtransaction = c.idTransaction
    GROUP   BY b.idItem, b.`name Item`, a.price, c.Date
    
    • SQLFiddle Demo

    UPDATE 2

    SELECT  b.`name Item`,
            SUM(a.qty) `Sold Quantity`,
            a.price `@ price`,
            (SUM(a.qty) * a.price) Total,
            d.`Name Customer`
    FROM    transaction_detail a    
            INNER JOIN Item b
                ON a.idItem = b.idItem
            INNER JOIN `transaction` c
                ON a.idtransaction = c.idTransaction
            INNER JOIN Customer d
                ON d.idCustomer = c.idCustomer
    GROUP   BY b.idItem, b.`name Item`, a.price, 
               MONTH(c.Date), YEAR(c.Date), d.`Name Customer`
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask some logic question here. Let say I have a
this is my first question in here, and I would like to ask if
I would like to ask such question, I have XML xsd`s, which generate beans
Just a knowledge question which I would like to ask: For example, I have
For my first question here I would like to ask you how you'd do
Just like Carl's question over here I would like to ask you (because I
I would like to ask something about query using mysql I have this table
I have an open question I would like to ask before starting development of
I have a yes or no question & answer. I would like to ask
I have already posted something similar here but I would like to ask the

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.