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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:41:04+00:00 2026-06-01T09:41:04+00:00

I have four tables in my database( notes , expense , category and items

  • 0

I have four tables in my database(notes, expense, category and items).

items table will have so many items on the particular category id
items table have fields

id(primary key), item name(text), unit(text), category id(foreign key)

category table will have just two fields
category table have fields

id(primary key), cat_id(integer), category name(text).

notes table is used to have a record for each shopping note.
notes table have fields

note_id(primary key), date(DATE), total cost(integer).

expense table is used to store the items purchased and its corresponding quantity and price under the particular shopping note using note id as the foreign key
expense table has fields

id(primary key), note_id(foreign key), quantity(integer), price(integer), item_name(text)

When I input the from date,to date and a particular category i need the items under that category that was purchaed between the from and to date.
i need a query that will give output as:

ITEM NAME           TOTALQTY          TOTALPRICE
carrot                5kg                 500

can anyone help me with a solution??

  • 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-01T09:41:05+00:00Added an answer on June 1, 2026 at 9:41 am

    Try this

    select A.name, sum(C.unit), A.unit, sum(C.price) 
    from items as A 
        INNER JOIN categories as B ON A.category=B._id
        INNER JOIN expenses as C ON A.name=C.item_name
        INNER JOIN notes as D ON C.Note_id=D._id
    where 
        D.date1 between '2012-01-01' and '2012-03-31' and B.name='Vegetables'
    group by
        A.name, A.unit
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my database structure I have four tables. Table LocalArea and Lanungaue have
I have these four tables (which are hierarchical, meanwhile) in my database: Table 1:
I have four tables in database. person(Perid ,firstname , lastname , gender) Research (Resid
I have a secondhand sale car database and four tables with relationships. Same column
i have four tables like below in sql server 2008 : TABLE 1 ->
I have four different tables, one main SPECIAL table containing only id's that reference
I have four tables in my database and i want to join that's and
I have two database tables, 'Lists' and 'Notes'. Lists has columns _id, listname Notes
I have four tables in my database: student : contain the student's ID and
I have four tables in a MySQL database and I am trying to create

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.