Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: M. Tanveer Ul Hassan Shaheen
  Where is M. Tanveer Ul Hassan Shaheen?
 Rahim Yar Khan
 Pakistan
 M. Tanveer Ul Hassan Shaheen
 Tags
Subject: RE: how to query
Thread ID: 311014 Message ID: 311016 # Views: 49 # Ratings: 2
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Tuesday, June 28, 2011 9:38:52 AM         
   


> Dear Experts!
> I have a table that has two record.
> ac_code dr_amount cr_amount
> ============================================
> 1-02-02-0014 500000
> 5-03-04-0110 50000
>
> i want following result
>
> 1-02-02-0014 500000(dr_amount) 5-03-04-0110(account of cr_amount)
>
> How to query
>
> Thanks & Regards
>
> Tanveer Ul hassan

Hi Tanveer,

In general, SQL requires primary and foreign key values, so the data you posted are not a "relational database" table in a SQL sense, those two rows do not seem to be related to each other, no "key" value in common, right?
If there are however actually only exactly two rows in that pseudo table, you can do something like this to get the desired result:
SELECT T1.ac_code, T1.dr_amount, T2.ac_code As accountOfCrAmount ;
FROM aTable T1, aTable T2 ;
WHERE T1.dr_amount > 0 AND T2.cr_amount > 0




hth
-Stefan

ENTIRE THREAD

how to query Posted by M. Tanveer Ul Hassan Shaheen @ 6/28/2011 9:11:00 AM
RE: how to query Posted by Stefan Wuebbe @ 6/28/2011 9:38:52 AM
RE: how to query Posted by M. Tanveer Ul Hassan Shaheen @ 6/28/2011 9:57:08 AM
RE: how to query Posted by Stefan Wuebbe @ 6/28/2011 10:09:59 AM
RE: how to query Posted by Cetin Basoz @ 6/28/2011 10:31:53 AM