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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SAME NAME IN COMPANY

Author  Topic 

vipinjha
Starting Member

21 Posts

Posted - 2012-01-25 : 02:07:22
Dear All ,
I want to find the name of employee having same name in organization
with their full name,address in sql 2008

name in emp table and details in add table
or i want to find details of employee having same surname



plesae do the needful

Thankx in advance



Vipin jha

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-25 : 03:30:57
Please give
table structure (create statement)
sample data (insert statement)
wanted result.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

vipinjha
Starting Member

21 Posts

Posted - 2012-01-25 : 04:08:37
Accounts table column :-
ACCOUNTS.PREFERREDPHONE,
ACCOUNTS.PREFERREDPHONETYPE ,
ACCOUNTS.ACCOUNTID,
ACCOUNTS.PREFERREDNAME,
ACCOUNTS.NAME

want to join with CMG on CMG.CUST_ID= ACCOUNTS.ORGKEY basis

I want to retrive only those records where having same ACCOUNTS.PREFERREDPHONE for multiple users.

i am using thgis query which is not giving proper record

SELECT ACCOUNTS.PREFERREDPHONE,ACCOUNTS.PREFERREDPHONETYPE ,ACCOUNTS.ACCOUNTID,ACCOUNTS.PREFERREDNAME,ACCOUNTS.NAME
FROM ACCOUNTS
WHERE (
SELECT COUNT(*) FROM ACCOUNTS
WHERE CMG.CUST_ID= ACCOUNTS.ORGKEY


thankx in advance

Vipin jha
) >0
ORDER BY ACCOUNTS.PREFERREDPHONE DESC



Vipin jha
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-01-25 : 04:48:35
Thank you for partial ignoring my request




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2012-01-25 : 09:13:10
something like:

select
<yourfields>
from
customertable
inner join
( select name, count(*) from customertable group by name having count(*) > 1 ) checkcounts
on
customertable.name = checkcounts.name


This psuedo code is the best I can do without table structures.
Go to Top of Page
   

- Advertisement -