Hello ,

Please help me (Urgent)

i have two tables
1. tbl_employeeinfo  2. tbl_networkpartloc
In these table i have common field called cCompany_ID.

1.
select count(tbl_employeeinfo.cCompany_ID)
from tbl_employeeinfo,tbl_networkpartloc
where tbl_employeeinfo.cCompany_ID = tbl_networkpartloc.cCompany_ID and
tbl_networkpartloc.iuPC < 50

/* In this query i am counting those companies have less than 50 PC */

I got the result

count(tbl_employeeinfo.cCompany_ID)
-----------------------------------
6

Now I fire

2.
select cCompany_Name,cEmployee_Name,CPhone_Mode,
sum(tbl_networkpartloc.iuPC)
from tbl_employeeinfo,tbl_networkpartloc
where tbl_employeeinfo.cCompany_ID = tbl_networkpartloc.cCompany_ID
and tbl_networkpartloc.iuPC < 50
group by cCompany_Name,cEmployee_Name,CPhone_Mode,
tbl_employeeinfo.cCompany_ID

I got the result

cCompany_Name     cEmployee_Name         CPhone_Mode
sum(tbl_networkpartloc.iuPC)
-------------                     --------------                         ---
--------                 ----------------------------
Case                                 Atul Kulkarni                     Phone
14
Core                                 Atul Kulkarni
Phone                          90
G-Tech                             NULL
NULL                           86
Oracle                              NULL
NULL                           15

Now the problem is that into out  table(tbl_networkpartloc) i am storing
multiple record with the same ID
suppose the count of  three rows i got the result  (10+30+50 = 90) for same
ID . It  treate as a different record.

What can i do I got the right result when the sum of  my PC is more the 50
(In my first and second Query )


Data

tbl_employeeinfo

cCompany_ID cCompany_Name
-----------             -------------
999                   Core
111                  ABC
112                   DEF
113                 GHI
114                 ABC1
115             DEF1
116             GHI1
345             Case
346             CBIT
232             ABCD
456             Oracle
678             EON Tech
890             TCS
367             SSI
123             G-Tech

tbl_networkpartloc

cCompany_ID     iuPC
-----------                 ----
232                     700
116                     590
115                    580
114                     570
113                     90
112                     80
111                     70
123                     43
367                    50
123                     43
999                     45
890                     435
346                 56
345                 14
456                 15
999                 45
678             234


Please Help me.


Manish Mehta
E-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to