(J.*********@gmail.com) writes:
I am balakumar here,
I have created a database of a company like the whole company employee
is under MD.
but i want number of employee forming a branches who is directly
reporting to there immediate senior.
I want the maximum number of subordinates reporting to their
immediate(Direct) senior.
what would be the <syntax> in nested select option.
I request you to send the <syntax> to my mail ID at the earliest.
A standard recommendation for this type of questions, is that your post
should include:
o CREATE TABLE statement for your table(s).
o INSERT statements with sample data.
o The desired result given the sample.
With that information, your chances to get a tested solution are very
good.
Without that information, and only a vague question, all you get are
more or less guesses. It sounds as if you are looking for how to run
a hierarchical query. In SQL 2000, there is on built-in syntax for this,
but look at
http://groups.google.com/group/comp....496712c9795f8f
for a way of doing it.
In SQL 2005 you can use something called Common Table Expression. If
you have SQL 2005, I suggest that you look up "WITH common table expression"
in Books Online for a discussion and some examples.
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx