If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Help With SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-08-10, 21:02
EIS2 EIS2 is offline
Registered User
 
Join Date: Aug 2010
Posts: 3
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 21:26.
Reply With Quote
  #2 (permalink)  
Old 08-09-10, 16:38
Steve Green Steve Green is offline
Registered User
 
Join Date: Dec 2007
Posts: 282
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
Reply With Quote
  #3 (permalink)  
Old 08-09-10, 23:09
EIS2 EIS2 is offline
Registered User
 
Join Date: Aug 2010
Posts: 3
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..
Reply With Quote
  #4 (permalink)  
Old 08-10-10, 07:25
Steve Green Steve Green is offline
Registered User
 
Join Date: Dec 2007
Posts: 282
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
Reply With Quote
  #5 (permalink)  
Old 08-10-10, 11:04
EIS2 EIS2 is offline
Registered User
 
Join Date: Aug 2010
Posts: 3
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
Reply With Quote
  #6 (permalink)  
Old 08-10-10, 11:18
Steve Green Steve Green is offline
Registered User
 
Join Date: Dec 2007
Posts: 282
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On