Re: query
Posted in 1999
Hi all,
Here is our answer to this query question.
This is our first ever reponse to any question and have put a lot of=20
efforts here, So its just our small drop in the ocean of INFORMIX.
##-------- Start Query -------##
select tab1.mgr_cd,count(*)
from tab2,tab1
where tab2.dept_cd =3D tab1.dept_cd
group by tab1.mgr_cd
having count(*) <=3D all(
=09=09select count(*)=09=09from tab2,tab1
=09=09where tab2.dept_cd =3D tab1.dept_cd
=09=09group by tab1.mgr_cd)
##------ End Query ----------##
If you are interested in having a look at the table then here is the inform=
ation
TABLE 1
##------- Start Table 1 ---------##
create temp table tab1
(dept_cd char(2),
mgr_cd char(2)
);
insert into tab1
values("OT","MN");
insert into tab1
values("SA","MN");
insert into tab1
values("AM","SZ");
insert into tab1
values("EM","SZ");
insert into tab1
values("SM","SZ");
insert into tab1
values("TM","NJ"); ##-- NJ is Nayan Jain (-;
select * from tab1;
##------- End of Table 1 -------##
##------- Start Table 2 ---------##
create temp table tab2
(dept_cd char(2),
emp_cd smallint
);
insert into tab2
values("OT",1);
insert into tab2
values("OT",7);
insert into tab2
values("OT",8);
insert into tab2
values("SA",2);
insert into tab2
values("TM",3);
insert into tab2
values("TM",9);
insert into tab2
values("EM",0);
insert into tab2
values("EM",4);
insert into tab2
values("SM",5);
insert into tab2
values("FA",6);
select * from tab2;
##------- End of Table 2 -------##
Hope that we are able to help you here.
Thanks to all the other people here, you all are too good in terms of knowl=
edge.WE are just freshie....and have learnt a lot just by being on this lis=
t.
Thanks again !
With Regards,
Nayan Jain, Ajay Singh, Girish Kadival and Deepa Rane.
(yeah it was a group effort)
Working on one of the Biggest INFORMIX project in India.
Tata Infotech Limited,Bombay, India.=20
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"The empires of the future are the empires of the mind."
=09=09=09=09=09-Winston Churchill
On Thu, 13 May 1999, Henk J. Sanders wrote:
> Hi folks.
>=20
> Probably a very simple query but I cann=B4t get the point.
>=20
> One tabel contains:
> - department_code
> - manager_code
>=20
> A manager can have MORE departments.
>=20
> The other table contains:
> - employee_nr
> - department_code
>=20
> Question:
>=20
> which manager controls the least nr. of employee=B4s?.
>=20
> Any idea.
>=20
> Many thanks.
>=20
>=20
>=20