| Author |
Topic |
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-28 : 09:49:50
|
| so... i have a client table that has 27000 rows ... and in that table I have multiple entries with the same name but different client number or different bank_account_number ...so I need to filtrate the duplicate entries ... by grouping the client name to the multiple clientnumbers or bank numbers.... so client xxxx --- 1213 -- xxxx --- 1214 --until now I've tried something like this :select t1.name ,t3.id ,t2.codfiscal from(select * from client ) t1 left outer join ( select codfiscal from clientgroup by codfiscal having count(codfiscal)>1 ) t2 on t1.codfiscal=t2.codfiscal inner join (select id from clientgroup by id having count(id)>1) as t3 on t1.id=t3.idorder by t1.name ascany ideas? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-28 : 09:59:57
|
Not without seeing your table structures.And some sample data.And some proper expected output. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-28 : 10:08:35
|
| table structure : CREATE TABLE [dbo].[Client]( [CompanyId] [int] NOT NULL CONSTRAINT [DF_Client_CompanyId] DEFAULT (1), [Id] [int] NOT NULL, [Name] [nvarchar](120) NULL, [PostCode] [nvarchar](50) NULL, [City] [nvarchar](50) NULL, [Street] [nvarchar](50) NULL, [HouseNumber] [nvarchar](50) NULL, [PayType] [char](1) NULL, [Branch] [char](1) NULL, [AlBranch] [char](2) NULL, [TelKor] [char](6) NULL, [TelNum] [char](15) NULL, [Email] [char](50) NULL, [Admin] [char](10) NULL, [DateofAdmin] [datetime] NULL, [CodFiscal] [nvarchar](50) NULL,sample data : ACS ACTIVE CENTER SRL 10081 ROR 4724596AD COMPUTER NETGATE SRL 10086 ROR 13611537AD D VERITAS 10432 ROR 14974506AD LINE SRL 13149 ROR 15498656expected data : ACCELUM SRL 10073 ROR 9881192ACELLUM SRL 10424 ROR 9881192ABSTARCT CONNECTION TIMISOARA 10068 ROR 15060973ABSTRACT CONNECTION TIMISOARA 11143 ROR 15060973the client number differs but the name is the same ... so I can group them into an excel table ... |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2009-05-28 : 10:48:43
|
| Maybe I'm missing something, but the sample data doesn't fit into the table that you gave and I can't seen any relationship between the sample info and the expected output. The names in the output don't appear in the sample, same with the 2nd and 4th columns.For it to be at all useful, sample data should have the same format as the table and the expected output should be based on the sample data.--Gail ShawSQL Server MVP |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-28 : 11:33:58
|
its not evident from posted data which field is client number, but it will be something likeSELECT t.*FROM YourTable tINNER JOIN (SELECT ClientName FROm YourTable GROUP BY ClientName HAVING COUNT(DISTINCT ClientNo)>1 )t1ON t1.ClientName=t.ClientName |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-29 : 02:14:24
|
| someone? |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-29 : 02:55:32
|
quote: Originally posted by GilaMonster Maybe I'm missing something, but the sample data doesn't fit into the table that you gave and I can't seen any relationship between the sample info and the expected output. The names in the output don't appear in the sample, same with the 2nd and 4th columns.For it to be at all useful, sample data should have the same format as the table and the expected output should be based on the sample data.--Gail ShawSQL Server MVP
so... as i mentioned in my first post... I only need those 3 columns... the rest.. it's not useful ... so I need the duplicate names... to have in the other 2 columns.. the diferent client no or bank no .... like client xxx ---with client no 123 and bank no 345and then still client xxx --- with other client no 321 and bank no 345 so a duplicate client name could have 2 diferences.. one in the client no column and/or bank no any ideas? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-29 : 03:11:20
|
i think you missed Gail's point.quote: Originally posted by GilaMonster Maybe I'm missing something, but the sample data doesn't fit into the table that you gave and I can't seen any relationship between the sample info and the expected output. The names in the output don't appear in the sample, same with the 2nd and 4th columns.For it to be at all useful, sample data should have the same format as the table and the expected output should be based on the sample data.--Gail ShawSQL Server MVP
can you explain how to get fromsample data :ACS ACTIVE CENTER SRL 10081 ROR 4724596AD COMPUTER NETGATE SRL 10086 ROR 13611537AD D VERITAS 10432 ROR 14974506AD LINE SRL 13149 ROR 15498656 TOexpected data :ACCELUM SRL 10073 ROR 9881192ACELLUM SRL 10424 ROR 9881192ABSTARCT CONNECTION TIMISOARA 10068 ROR 15060973ABSTRACT CONNECTION TIMISOARA 11143 ROR 15060973 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-29 : 04:05:55
|
| the names differ... those are totally random selections.... IF u read what I posted u will understand... the expected data only suggest... that the duplicate names have different client numbers or bank numbers... I found those in the expected data and put them in my post only to suggest what I want to obtain ! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-29 : 04:16:06
|
You are not helping us to understand your problem by providing random result that is not corresponding to the sample data provided.What we are expecting is you can post the sample data and the expected result from the sample data you posted. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-05-29 : 05:56:17
|
| this is what I expect ... all grouped like this... but only the ones that have duplicates in the name column... and right next to it are the client_no column... witch are different on every case... because not one client has the same client number....so ... expected data : name Client_no Bank_no SECA DISTRIBUTION SRL 10540 RO5522510SECA DISTRIBUTION SRL 10541 ROR5522510random data : NAME Client_no Bank_noASOC DE PROP SEL 28-30 10894 RO11379369IN MEMORIAM SRL 10901 RO3861404AJVPS 10909 RO4919121BAD AXEL SRL 10913 ROR 1283541AQUILA PART PROD COM SRL 10916 RO6484554SCM CONSTRUCTORUL 10919 RO74148MOBIL TILEAGD SA 10925 ROR 117230TELECONSTRUCTIA SA 10954 ROR217205FARMEXPERT DCI 10986 ROR13758814PANGRAM SA 10992 RO6695683WORLD MEDIATRANS SRL 11014 RORO9480727BAD AXEL SRL 11067 ROR 1283541VOLKSBANK ROMANIA SA 11096 RO15014365AUTOTOTAL SRL 11101 ROR14847561EUROM BANK 11129 ROR4905630ANKO POMP SRL 11130 ROR4905630TEMAD CO SRL 11139 RO6620400SUNLIGHT ROMANIA SRL 11142 RO14525582FINISIA 11149 NULLINTERSTAR CHIM SA 11154 ROR 6614930MUNAX SRL 11156 ROR 15380528FINISIA 11158 ROR 11616325PF GABOR GAVRIL 11163 RO1760510054679RELUXA COM 11186 NULLRELUXA COM 11187 ROR 5397476STARTELEFONICA SRL 11238 NULLFUNDATIA GABOR DENES 11246 ROR 7111863NEW START SRL 11264 ROR 65921JT INTERNATIONAL ROMANIA SRL 11272 RO5110535ZAGROS SRL 11324 RO3686940ATLASSIB SRL 11327 RO18162471WEST PALACE SRL 11339 RO6734936VALROM INDUSTRIE SRL 11345 RO8529679COMFRUCT SA 11363 ROR47208BIZOOFRUCT BIHARIA SA 11373 RO113174COMPUTER FORCE SRL 11390 RO4819289GENERALI ASIGURARI SA 11410 RORO 4134668COMCEREAL SA 11414 ROR 8216582UNISEM SA 11418 RORO9148540PRIMA GUARD SECURITY GROUP 11466 ROR11267756NICOLIMP SRL 11494 ROR CUI 1590361PF GABOR GAVRIL 11508 NULLPPS 11509 NULLPPS 11514 ROCUI 14939282FUSTELLIFICIO AGRI PROD SRL 11528 ROR9358283So... u will see that there are duplicates... but I dont wanna select only those... anything else is useless ! |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-05-29 : 11:52:19
|
quote: so... as i mentioned in my first post... I only need those 3 columns... the rest.. it's not useful ... so I need the duplicate names
quote: So... u will see that there are duplicates... but I dont wanna select only those... anything else is useless !
I'm still confused as to what you want. I *think* you are asking for Clients with the same Name that have different IDs and CodFiscal values. Is that correct?SELECT DISTINCT Name, ID, CodFiscalFROM ClientINNER JOIN ( SELECT Name FROM Client GROUP BY Name HAVING COUNT(Name) > 1 ) AS T ON Client.Name = T.Name |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-05-29 : 12:43:16
|
| Also, try following the first link in my signature. It will show you how to give sample data and output that are in a usable format.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|