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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:38:35+00:00 2026-06-15T03:38:35+00:00

I have two tables like below Book id TID reserveddate fee1 fee2 fee3 Noofplayers

  • 0

I have two tables like below

Book

id TID reserveddate fee1 fee2 fee3 Noofplayers total
-------------------------------------
1   11  2012-11-25 100  200  300      3        800
2   12  2012-11-25 100  200  300      3        800
3   13  2012-11-28 200  100  200      1        500

Players

 TID  fee1 fee2 
-------------------------------------
  11  100  200  
  11  100  200  
  11  100  200 
  12  100  200  
  12  100  200
  12  100  200
  13  200  100  

now i would like to retrieve data from both tables with group by Reserveddate.

I have a query,

select sum(b.fee1)+sum(b.fee2)+sum(a.fee3) as total 
from Players b,book a where a.TID = b.TID  and a.ReservedDate ='25-nov-2012' 
group by a.ReservedDate

the above query in sum(fee3) adding 3(noofplayers) times i want to add one time book table.

could you please update the query as per client requirement…

  • 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-15T03:38:38+00:00Added an answer on June 15, 2026 at 3:38 am

    I believe this would work, it would give total of 2400:

    select  sum(b.fee1_fee2_totalPerPlayer) + sum(a.fee3) as total 
    from    book a
    join    (
                select  TID,
                        sum(fee1) + sum(fee2) 
                            as fee1_fee2_totalPerPlayer
                from    Players
                group   by TID
            ) b on
            a.TID = b.TID
    where   a.ReservedDate ='2012-11-25' 
    group by a.ReservedDate
    

    Here is how the total is getting calculated:

    For TID=11: 300 (sum of Players.fee1) + 600 (sum of Players.fee2) = 900

    For TID=12: 300 (sum of Players.fee1) + 600 (sum of Players.fee2) = 900

    900 + 900 = 1800

    1800 + 600 (sum of Book.fee3 for date ‘2012-11-25’) = 2400

    Here is an example: SQL Fiddle

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

Sidebar

Related Questions

I have two tables names book_list and book_category . Schema is like below: book_list
I'm using SQL Server 2008. Let's say I have two hypothetical tables like below:
I have two tables like the ones below. I need to find what exchangeRate
I have two tables like the below one in my DB. In the first
I have two MySQL tables named 'nodes' and 'joinTable' like shown below. I need
I have a db with two tables like these below, page table pg_id title
I have two tables like below, mysql> select * from Books ; +----+------+------------+----------+----------+ |
I have two database tables with some demo data like shown below Create table
I have two tables with like below codes: Table: Accounts id | username |
I have two tables below. Item Table This Item Table contains ItemId and Total

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.