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 - 2006-02-27 : 12:06:01
|
| Prasad writes "Hello all,I need your help to solve the following:When I give the following sql:Select datepart(month,crdate) crdate, shortdesc from vwBlogEntries where contributor='testnewsadmin' group by crdate, shortdescI get the following output:crdate shortdesc===================5 As a person of the conservative persuasion1 Growth in Maharashtra, the most favoured destination 1 Kotak Mahindra Investments Ltd has announced2 THE Government has clarified thatActually, my requirement is like following.crdate shortdesc===================5 As a person of the conservative persuasion1 Growth in Maharashtra, the most favoured destination Kotak Mahindra Investments Ltd has announced2 THE Government has clarified thatWhich means, I want to group based on crdate and supress the repeating values.Any help on this is most welcome.Thanks,Prasad." |
|
|
jimmy_a
Starting Member
38 Posts |
Posted - 2006-02-28 : 00:30:57
|
| I hope u cant do this in a single query .. either u need to use cursor or looping mechanism"A smile is an inexpensive way to improve your looks" |
 |
|
|
jimmy_a
Starting Member
38 Posts |
Posted - 2006-02-28 : 00:36:36
|
| U can try like this declare cursor selectopenfetch @empcodewhile @@fetchstatus <> 0if @empcodetmp <> @empcodebegin set @empcodetmp = empcodeendelsebegin set @empcodetmp = nullendinsert into temp select @empcodetmp,@empnamefetch nextloopclose cursordeactive cursor"A smile is an inexpensive way to improve your looks" |
 |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-02-28 : 00:52:38
|
| Hi,Refer this link..http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-28 : 01:21:33
|
| >>Which means, I want to group based on crdate and supress the repeating values.Where do you want to show the data?Use Front End application or Reports to Suppress the column if duplicated. Dont try to do this in SQLMadhivananFailing to plan is Planning to fail |
 |
|
|
jimmy_a
Starting Member
38 Posts |
Posted - 2006-02-28 : 01:41:47
|
| Is there any draw back of doing this in backend madhi ???"A smile is an inexpensive way to improve your looks" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-28 : 01:49:12
|
| It will be ineffecient to do this in SQL. Reports are there for formatting or Displaying the data in the format we want. Suppressing Duplicate values should be done in Reports.Also read this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56067MadhivananFailing to plan is Planning to fail |
 |
|
|
jimmy_a
Starting Member
38 Posts |
Posted - 2006-02-28 : 02:26:53
|
| Thanks for ur info madhi..."A smile is an inexpensive way to improve your looks" |
 |
|
|
|
|
|
|
|