Click here to Skip to main content
15,887,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three tables and its design is as below.

SCHEMETRN1:
ID	SCHEME_ID	FAMILYCODE	SCHEME_YEAR
5500	    7	             1	            2013


SCHEMETRN2:
FAMILYCODE	SCHEME_ID	      SCHEME_YEAR
1	           9	                  2013
1	           9	                  2013
2	           1	                  2013
2	           1	                  2013
8	           1	                  2013
277	           9	                  2013
277	           9	                  2013
277	           9	                  2013


DATAFILE:
FAMILYCODE   NAME     AGE
     1       ABC       25
     1       PQR       70
     2       XYZ       35
     2       SDH       45


Output should be as below:
FAMILYCODE NAME No of Scheme Used
1 ABC 2
2 XYZ 1


Now what I want is to display from DATAFILE table only one record per familycode i.e
schemetrn2 table has familycode 1 so I want to display only one record for familycode 1 from Datafile table.

Also Schemetrn1 and schemetrn2 has familycode 1 so I want to get no of counts as 2 for familycode 1 with the above query.
Can any1 help me please.
Posted
Updated 12-Aug-13 4:06am
v4
Comments
Maciej Los 10-Aug-13 13:42pm    
Not clear ;(
Please post example output. Use "Improve question" widget.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900