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
 Transact-SQL (2000)
 Selecting a couple records from many

Author  Topic 

rickratayczak
Starting Member

5 Posts

Posted - 2003-01-07 : 01:52:50

Table Schema

CREATE TABLE [dbo].[Rotation] (
[IncNum] [int] IDENTITY (1, 1) NOT NULL ,
[Filename] [varchar] (1500) ,
[SingerName] [varchar] (150) NOT NULL ,
[DateAdded] [datetime] NOT NULL
) ON [PRIMARY]



There is an constraint on Filename/SingerName

Example Table Data:

08 Yoakum, Dwight - Crazy Little Thing Called Love Rick 2003-01-06 21:21:30.957
09 Sc7522 - 11 - Reba Mcentire - Fancy Brianna 2003-01-06 21:22:05.707
10 Creed - My Sacrifice (Sc8765-02) Rick 2003-01-06 21:22:49.410
11 Childrens-Traditional - Alphabet Song, The Brianna 2003-01-06 21:23:07.137
12 07 Tracy Chapman - Give Me One Reason Kristy 2003-01-06 21:27:22.673


Here is the thing I would like to do.
Select the top 2 songs from each singer, unless the record count > 6 then I would like to select 1 song from each singer as return all this as a result set.

Something like
select top 2 from singers where SingerName = 'Rick'

But do this for all the singers, then return it as one result set or maybe data shaping?

Thanks for your help!

Rick


Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-01-07 : 07:27:11
Read through this thread. If you can't get it working, post the dml you are working with ...

Jay White
{0}
Go to Top of Page
   

- Advertisement -