Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
subhaoviya
Posting Yak Master
135 Posts |
Posted - 2010-06-23 : 13:18:09
|
| i have 4 tables likeTable 1 PlanID plannameTable 2 GPID PlanIDTable 3 GPID MEMIDTable 4 MEMIDI need to get the count of memid for each planid.how to do thatplease help me |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2010-06-23 : 13:29:15
|
| you need to join the tables firstSELECT a.PlanID, c.MEMID, COUNT(*) FROM TABLE1 aINNER JOIN Table2 bON a.PlanID = b.PlanIdINNER JOIN Table3 cON b.GPID = c.GPID GROUP BY a.PlanID, c.MEMIDI don't think you need table4If you want some more detailed help, you have to supply us with.....come say it!DETAILSBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
subhaoviya
Posting Yak Master
135 Posts |
Posted - 2010-06-23 : 13:46:35
|
| thanks a lot for you reply.but it is not working properly. it display plan count for each memidthanksby subha |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-06-23 : 14:17:23
|
quote: Originally posted by subhaoviya thanks a lot for you reply.but it is not working properly. it display plan count for each memidthanksby subha
This?SELECT a.PlanID,COUNT(c.MEMID)FROM TABLE1 aINNER JOIN Table2 bON a.PlanID = b.PlanIdINNER JOIN Table3 cON b.GPID = c.GPIDGROUP BY a.PlanID If the above also is not working as expected you need to post some sample data.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
|
|
|