Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-Server-2008
i have three tables 1. member_commission 2. member_payment 3. member_detail
now i want to join all three tables to get common query is..
select r.ref_id,sum(r.ref_com),m.mname,p.bal_amt from member_commission  as r inner join member_detail as m
on r.ref_id=m.mem_id inner join member_payment  as p on r.ref_id=p.mem_id where r.pay_check='unpaid' group by r.ref_id
to get total commission earn by all different members,their id and their name and finally last unpaid balance
the details are coming from all these three tables but my query is not working,
there are some error on mname
please give me some exactly idea how to fetch details from three tables ...
Posted 16-Nov-12 22:11pm
Edited 17-Nov-12 0:40am
vishal jodh at 17-Nov-12 4:09am
pls post table Structure of u r query
Miss Maheshwari at 17-Nov-12 4:41am
table member_commission
cid ref_type ref_id ref_com mid time pay_check
1 indirect 106 1 113 2012-11-16 22:32:38.000 NULL
2 indirect 103 2 113 2012-11-16 22:32:38.000 NULL
3 indirect 101 3 113 2012-11-16 22:32:38.000 NULL
4 direct 106 100 113 2012-11-16 22:32:38.000 NULL
table member_payment
pid ref_id payamt totamt balamt date
1 106 101 201 100 2012-11-16 00:00:00.000
table member_detail
name userid mid add and other field
a abc 102 a abshbjs asa 11 asa 12112 1112012102CL 1 111 101 NULL NULL
a neetu1 103 n n 545 gg 46 gjh ttut 21120121033F 2 4 102 NULL
a a 104 aa asa a A aaa a 2112012104QA 2 22223 102 NULL
x x 105 xx s x x x x 2112012105ZQ 2 545646 103 NULL
123 ayaan 106 aa Indore nmbdj jsd bkjs bkjs nash 011201273813 0 198293 102 NULL

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

give more detail about tables
Miss Maheshwari at 17-Nov-12 4:37am
table member_detail is having complete detail of members..
table member_commission is having detail of commission earned by members
and table member_payment is having detail of commission paid to member by admin and balance of of member
Nelek at 17-Nov-12 5:02am
Please don't post solutions to add information, to ask something or to comment another user.
- To add information to your message, you can use the widget "Improve question" / "Improve solution" at the bottom of your text.
- To answer a user, you can use the widget "Have a question or comment?" (as I am doing right now with you) or the widget "reply" in another comment.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,478
1 OriginalGriff 6,516
2 Peter Leow 3,587
3 Zoltán Zörgő 3,406
4 Richard MacCutchan 2,397

Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100