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 |
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2009-03-04 : 12:57:25
|
| Hi,I have a table that contains the following fields:app_id intsujbect_id intissue_id intdate_reported datetimeagent_id intI have a query such as the following:Select app_id, subject_id,issue_id fromtbl_issuesReportedwhere date_reported between @date1 and @date2However, i need to change the query and show the 10 most issues that were reported between the dates selected.Any help will be appreciated.ThanksWhisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-04 : 13:09:25
|
| [code]Select top 10 with ties app_id, subject_id,issue_id fromtbl_issuesReportedwhere date_reported between @date1 and @date2group by app_id, subject_id,issue_idorder by count(*) desc[/code] |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
subhash chandra
Starting Member
40 Posts |
Posted - 2009-03-04 : 17:21:14
|
| You are asking to most issues that were reported between given two dates but missed what most?If mst recent then Tara's query with a little bit change ORDER BY date_reported DESC |
 |
|
|
malawneh
Starting Member
24 Posts |
Posted - 2009-03-04 : 18:37:55
|
| SELECT TOP 10 app_id , subject_id , issue_idFROM tbl_issuesReportedWHERE date_reported BETWEEN @Date1 AND @Date2GROUP BY app_id , subject_id , issue_idORDER BY COUNT(issue_id) DESCMichael Alawneh, DBA |
 |
|
|
|
|
|
|
|