Results 1 to 6 of 6

Thread: Help With SQL

  1. #1
    Join Date
    Aug 2010
    Posts
    4

    Unanswered: Help With SQL

    I have a Paradox database with several tables. The database application is used by the church treasurer to record financial transactions. The main table consists of the transaction date, the transaction type (check or deposit), and a primary key to link to check and deposit tables. The check and deposit tables link to check detail and deposit detail tables where amounts and budget codes are assigned. For example, a single check of $100 might consist of $25 for office supplies and $75 for new equipment. Similarly a $1000 deposit might consist of $800 undesignated and $200 for a special offering.

    I can retrieve the transactions for checks with budget code 101.3 with the following SQL statement:

    "SELECT * FROM Treas_Header INNER JOIN Treas_Check
    ON Treas_Header.MasterHdrKey=Treas_Check.MasterHdrKey
    INNER JOIN Treas_CheckDetail
    ON Treas_Check.CheckKey=Treas_CheckDetail.CheckKey
    WHERE Treas_CheckDetail.BudgetCode='101.3';

    Similarly, I can retrieve the transactions for deposits with budget code 101.3 with the following SQL statement:

    SELECT *
    FROM Treas_Header INNER JOIN Treas_Deposit
    ON Treas_Header.MasterHdrKey=Treas_Deposit.MasterHdrK ey
    INNER JOIN Treas_DepositDetail
    ON Treas_Deposit.DepositKey=Treas_DepositDetail.Maste rDepositKey
    WHERE Treas_DepositDetail.BudgetCode='101.3';

    My problem is I want both of the results returned together. How can I modify the SQL statements to return both sets of results?

    Thank You...
    Earl
    Last edited by EIS2; 08-08-10 at 22:26.

  2. #2
    Join Date
    Dec 2007
    Posts
    369
    you need to do it in two passes, and add the results together into one table.. the "line item" data is coming from two separate tables, not two different rules from one table.. if you did it as one query, your result structure wouldn't be what you're expecting..
    --
    Steven Green - Myrtle Beach, South Carolina USA

    http://www.OasisTradingPost.com

    Oasis Trading Post
    - Collectibles and Memorabilia
    - Vintage Lego Sets and Supplies
    - and Paradox Support, too

  3. #3
    Join Date
    Aug 2010
    Posts
    4
    Steve,

    Thank you for your reply. How do I perform the query in two passes? I am relatively new to SQL and quite confused as to the language. I have been reading two books on SQL for beginners, but none have addressed the issue I have.

    The SQL Query loads data into five DBGrids in C++ Builder 2010; one DBGrid per table. Working queries execute almost instantly and bad queries completely lock up the program. I waited a long time to see if the bad query would return anything and it did not. What does a bad query do that locks up a program and is there any way to terminate a bad query other than terminating the program?

    Thanks again...
    Earl




    Quote Originally Posted by Steve Green View Post
    you need to do it in two passes, and add the results together into one table.. the "line item" data is coming from two separate tables, not two different rules from one table.. if you did it as one query, your result structure wouldn't be what you're expecting..

  4. #4
    Join Date
    Dec 2007
    Posts
    369
    How do I perform the query in two passes?

    that is what you're showing us now.. two queries, then you combine the results into one table..


    The SQL Query loads data into five DBGrids in C++ Builder 2010

    ok, we stop right here.. if this is a C+ app, not a paradox app, you're asking questions in the wrong place..

    if this is a paradox app (paradox software and paradox tables) you could be using the excellent built-in query tools.. in this case, the question and answer would be the same, but the tools would be different, and simpler..

    if this is another platform, just using paradox tables, you need to direct your questions to support for *that* platform..
    --
    Steven Green - Myrtle Beach, South Carolina USA

    http://www.OasisTradingPost.com

    Oasis Trading Post
    - Collectibles and Memorabilia
    - Vintage Lego Sets and Supplies
    - and Paradox Support, too

  5. #5
    Join Date
    Aug 2010
    Posts
    4
    Steve,

    Thanks again for the reply. This is a special C++ application, but the underlying tables were designed using Database Desktop using the Paradox option. I assumed there were folks on this forum that used SQL directly. I'm quite sure that the problem is doable if I can find the right SQL code.

    Thanks Again...
    Earl

  6. #6
    Join Date
    Dec 2007
    Posts
    369
    This is a special C++ application

    ok, but this is the paradox topic (paradox the software and/or paradox the table format).. you need to post in the appropriate topic, sorry..
    --
    Steven Green - Myrtle Beach, South Carolina USA

    http://www.OasisTradingPost.com

    Oasis Trading Post
    - Collectibles and Memorabilia
    - Vintage Lego Sets and Supplies
    - and Paradox Support, too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •