SQL Query from diffrent tables - How to

Posted on 2004-11-13
Last Modified: 2008-07-03

I have 3 databases like below;

MUSID : autoinc

TekID : autoinc
MUSID : number

DB3ID : autoinc
TekID: number
Money : currency
MoneyID : number

I want to select the sum of money grouping by moneyid and MUSID.
That is like
MUSID  MoneyID  Sum of Money
1              1                100
1              2                150
2              1                98

How can i do that with sql code ? I'm programming with delphi and none of the tables hav relationship between.


Question by:mece
    LVL 8

    Accepted Solution

    select a.MusID, b.MoneyID, Sum(Money)
    from db2 a join
    db3 b
    on a.tekid = b.tekid
    Group by a.MusID, b.MoneyID

    is the sql statement you are after if these are 3 tables which I am guessing is what you mean.

    Author Comment

    thanx for the way

    it works with left join command
    i learned it

    LVL 8

    Expert Comment

    oh right cool, happy to help.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now