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 |
|
jharr100
Starting Member
2 Posts |
Posted - 2008-11-21 : 00:09:32
|
| I need help---lets say my results from a query looks like thiscourse id description course credit instructor151 csc class 3 smith151 csc class 3 davis151 csc class 3 scott233 csc 2class 3 robinson233 csc 2class 3 elliot444 csc 3class 3 rogers554 csc 4class 3 chenso how would i only do a distinct on one column to get an output like:course id description course credit instructor151 csc class 3 smith csc class 3 davis csc class 3 scott233 csc 2class 3 robinson csc 2class 3 elliot444 csc 3class 3 rogers554 csc 4class 3 chenIve tried using distinct, using aggregate functions and using group by and order by and nothing gives me that exact outputPLEASE HELP!! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-21 : 00:22:23
|
| this is just a presentation issue. Most reporting applications have property build on it. its called discard duplicates or Hide duplicates. which report application are you using?you dont need to tweak your sql for this. |
 |
|
|
jharr100
Starting Member
2 Posts |
Posted - 2008-11-21 : 00:33:37
|
| um I am not sure the reporting application... I am new to this... this is actually for an assignment and I have searched and searched and can't find out how |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-21 : 01:34:15
|
| [code]SELECT CASE WHEN Seq=1 THEN CAST(courseid S varchar(10)) ELSE '' END AS courseid,description, course, credit, instructorFROM(SELECT ROW_NUMBER() OVER (PARTITION BY courseid ORDER BY instructor desc) as seq,*FROM YourTable)t[/code] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-21 : 02:53:10
|
quote: Originally posted by jharr100 um I am not sure the reporting application... I am new to this... this is actually for an assignment and I have searched and searched and can't find out how
Tell the person who assingned this task that this should be done in the presentation layerMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|