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 |
|
AJones
Starting Member
3 Posts |
Posted - 2004-12-21 : 00:26:48
|
| Sorry if this has been done to death, I've just gotten back into serious SQL after a couple years break. I used to know how to do this.I have a table containing fax numbers as one of the columns. I need to extract a list of fax numbers without duplicates. The table isn't designed as well as it should be, but it's what I must work with.Raw Table Rows:FaxNo CoName Contact MoreColums...123 456 7890 Bob's House O Stuff Bob ...123 456 7890 Bob's House O Stuff Fred ...123 456 7890 Bob's House O Stuff George ...213 999 1212 Junk Stuff Is Us Harvey ... 405 110 5157 We Sell Widgets Isobel ...405 110 5157 We Sell Widgets Yvette ...101 605 1015 Spacely Sprockets Rosie ...Desired Result:FaxNo CoName123 456 7890 Bob's House O Stuff213 999 1212 Junk Stuff Is Us405 110 5157 We Sell Widgets101 605 1015 Spacely SprocketsSo I have a start ofSELECT FaxNo, CoName FROM MyTableWHERE My mind goes blank here.Thanks for any help! |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-12-21 : 02:14:17
|
| SELECT DISTINCT FaxNo, CoName FROM MyTableKristen |
 |
|
|
AJones
Starting Member
3 Posts |
Posted - 2004-12-21 : 10:36:21
|
| Thanks for the reply. The hitch is that column order is non-negotiable, so DISTINCT won't do the trick. I'm creating an import for another process that expects stuff to be in a certain order. My example from last night was a bleary-eyed bad one, mea culpa. Now that I'm back at my desk....SELECT rfID AS ID, rfName AS Name, rfCompany AS Company, rfAddress AS Address, rfCityState AS CityState, rfFax1 AS Fax1, rfFax2 AS Fax2, rfVoice1 AS Voice1, rfVoice2 AS Voice2, rfBillCode1 AS BillCode1, rfBillCode2 AS BillCode2, rfNotes AS NotesFROM MyTableORDER BY rfFax1 ASC |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-21 : 10:53:12
|
| how can we possibily help you if you don't provide us with accurate sample data and expected results, along with the logic you'd like apply to acheive those results?- Jeff |
 |
|
|
AJones
Starting Member
3 Posts |
Posted - 2004-12-21 : 10:56:51
|
| You're absolutely right. Shame on me. I won't trouble you any more. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-12-21 : 11:30:48
|
| no, you can trouble us as much as you like. just help us to help you. We're trying to figure out what the question is you are asking, as opposed to trying to figure out the answer.with your latest SELECT, it has nothing to do with the sample data. So help us out, give us some relevant sample data, and then we'll be more than happy to help you out. But we can't be expected to help you if you don't provide us with enough information. Does this make sense?- Jeff |
 |
|
|
|
|
|
|
|