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 |
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2011-06-06 : 07:21:29
|
| Hi, I've got a table with titles.I want to create a query which results in a list of unique characters which do exist as first characters of the titles.So if the table looks like this:ID Title1 Bear2 Wolf3 Apple4 Beast5 Window6 SwallowIt would result in:ABSWHow can I do that? |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-06 : 07:34:04
|
| select distinct left(fld,1)from tbl==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2011-06-06 : 08:00:01
|
| That's great!!!But now, what if I had three tables with titles, and still want to return one list?The secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2011-06-06 : 08:08:54
|
| Step 1: Normalize your database.Step 2: ????Step 3: Profit.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-06 : 08:10:24
|
select left(Title,1) from tbl1UNIONselect left(Title,1) from tbl2and so on...The UNION will give distinct values... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2011-06-06 : 08:53:05
|
| Ok, that was easier then I suspected.Thanks to you all...The secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
|
|
|