Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FPD25, 2 Queries on a same base, T-Style reporting
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00629581
Message ID:
00630023
Views:
19
Thanks Sergey for your response.
Sorry I had misrepresented the data thing so you had to create a more complicated query but I get the gist of the thing.

My actual representation should have been this:
>>Qurey 1
>>
>>fld1qry1   fld2qry1
>>  data1      data1
>>  data2      data1
>>
>>
>>
>>Qurey 2
>>
>>fld1qry2  fld2qry2
>>  data1      data1
>>  data2      data2
>>  data3      data3
>>
>>
>>
>>
>>fld1qry1   fld2qry1   fld1qyr2  fld2qry2
>>  data1      data1      data1     data1
>>  data2      data2      data2     data2
>>                        data3     data3
>>
Just of the top based on your response:
SELECT *, RECNO() as RecID ;
  FROM qyr1 ;
  INTO CURSOR qry11

SELECT *, RECNO() as RecID ;
  FROM qyr2 ;
  INTO CURSOR qry22

SELECT * ;
  FROM qyr11, qry22 ;
  WHERE qry11.recid = qry22.recid ;
UNION ALL ;
SELECT * ;
  FROM qyr11, qry22 ;
  WHERE qry11.recid # qry22.recid ;
  INTO CURSOR whatever
Please comment. Thanks

>Something like
* Add record number as a record Id to both queries
>*   to match them later
>Select fld1qry1, fld2qry1, Recno() as RecId ;
>	FROM Query1 ;
>	INTO CURSOR crsQ1
>Select fld1qry2, fld2qry2, Recno() as RecId ;
>	FROM Query2 ;
>	INTO CURSOR crsQ2
>* Select all records with matching Id's (recno)
>*     and add unmatched records from the second query
>* Assumes that size of fld1qry1 and fld2qry1 is 20 chars
>SELECT fld1qry1, fld2qry1, fld1qry2, fld2qry2 ;
>	FROM crsQ1, crsQ2 ;
>	WHERE crsQ1.RecId = crsQ2.RecId ;
>UNION ;
>SELECT Space(20), Space(20), fld1qry2, fld2qry2 ;
>	FROM crsQ2 ;
>	WHERE crsQ2.RecId NOT In ( ;
>		Select RecId FROM crsQ1)  ;
>INTO CURSOR crsrep	
>>Hi all
>>
>>I have 2 query result sets both based on a common criteria but with different amount of data in each.
>>
>>Now I want to print them side by side using report writer (with a PRG this is possible), so how can I combine these 2 into one union where there are empty records for a fields, say from query 1. eg.
>>
>>Qurey 1
>>
>>fld1qry1   fld2qry1
>>  data       data
>>  data       data
>>
>>
>>
>>Qurey 2
>>
>>fld1qry2  fld2qry2
>>  data       data
>>  data       data
>>  data       data
>>
>>
>>
>>
>>fld1qry1   fld2qry1   fld1qyr2  fld2qry2
>>  data       data       data      data
>>  data       data       data      data
>>                        data      data
>>                        data      data
>>                        data      data
>>
>>
>>Thanks
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform