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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-01-08 : 08:54:45
|
Dan writes "Just wondering if I could pick your brain on a particular SQL query I'm battling with..... :-)I'm not too sure if it is going to be possible....I have a table with a list of the courses that we offer and I am wanting to generate a query that will return all the Subject areas eg COMP, ACCT, ECON etcIn the 'subject' Table I have a column called 'subjectCode' which stores the Code for each subject eg COMP101, COMP204, ACCT101I don't know if it is possible to query the table and get a table of just the Subject Areas, but if it only returned one COMP code(say COMP101) and one ACCT Code(say ACCT101) I could then use ASP.NET to use only the first 4 letters from the returned rows.actual table:subjectCodeACCT101ACCT104ACCT204COMP104COMP108COMP204ECON312ECON101ECON214...Returned query could look like this:subjectCodeACCT101COMP104ECON312...-or ideallysubjectCodeACCTCOMPECON...I appreciate any help you may be able to give!" |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-01-08 : 09:10:43
|
select distinct left(subjectCode,4) from tbl==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-01-08 : 09:24:10
|
difficult query?Nr didn't even break a sweat on that one!- Jeff |
|
|
Peter Dutch
Posting Yak Master
127 Posts |
Posted - 2003-01-08 : 09:33:33
|
and the fun thing is, he got the same anser YESTERDAY from the forums on asp.net.....(would that be considered a crosspost too :) ) |
|
|
|
|
|