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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query with Group By and Ordering

Author  Topic 

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2001-04-10 : 12:07:12
Well,

I have been working on a query for the past
few days that I cannot conquer, I was hoping I could get some direction from the master's of sql.

I have 3 tables as such.

Resident
ResidentID | Name | bookingDate

Offense
offenseID | residentid | literalid | oLevel

Literal
literalid | description

So, basically, I need a report
of the count of new admits for a month,
grouped by literal.description

but the issues is this.
there can be many instances of a resident in the Offense table. I need the Most lethal record only for each resident which is categorized by oLevel.

the oLevel column can have F,G or M
F = Worst
G = Middle
M = Least

so an alphabetical sort will work,
but I have twisted the sql every which way but loose and cannot come up with a reasonable solution.

I have a backup plan to use a vbs array, but if i can make this query work, it builds on many others to come, so a *real* solution would be great.

Thanks for the time.

Software Composer
   

- Advertisement -