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.
| Author |
Topic |
|
pupli
Starting Member
8 Posts |
Posted - 2008-08-06 : 11:19:19
|
| hello everybody,I have a table (only one table) with several records in it.Now, I want to build a query which will return all the records whose field's value is equal (we assume that we pre-chose a column)for exampleTable1 ==============================================================|CustID | Name | SName | NrTEL | E-Mail | Profession | ==============================================================Table1 ==============================================================|CustID | Name | SName | NrTEL | E-Mail | Profession | -------------------------------------------------------------- | 102 | abcde | asdf | 12345 | aa@s.com | Director || 105 | aderw | wert | 12233 | aw@s.com | Manager | | 123 | ertyu | oiui | 15456 | eo@s.com | Specialist || 245 | abcde | iuyt | 14254 | ai@s.com | Specialist || 256 | kjfur | asdf | 12589 | ka@s.com | Manager | ==============================================================************Our query would have been like this:*********************************************Display all the people with the same professionand the result should be like this: ************ *Result SET* ************==============================================================|CustID | Name | SName | NrTEL | E-Mail | Profession | -------------------------------------------------------------- | 105 | aderw | wert | 12233 | aw@s.com | Manager | | 123 | ertyu | oiui | 15456 | eo@s.com | Specialist || 245 | abcde | iuyt | 14254 | ai@s.com | Specialist || 256 | kjfur | asdf | 12589 | ka@s.com | Manager | ==============================================================thank you to everybodyIf I only could..... |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-08-06 : 11:29:40
|
| select * from Table1where Profession in (select Professionfrom Table1group by Professionhaving count(*) > 1)-- maybe: order by ProfessionWebfred |
 |
|
|
pupli
Starting Member
8 Posts |
Posted - 2008-08-07 : 10:33:59
|
| thank you webfredthank youIf I only could..... |
 |
|
|
|
|
|