He is asking you to normalize your table...you don't follow that?If you are using SQL 2005 or above, here is one way of doing it..(not the normalization...but the result that you want..
)declare @cnt intselect @cnt = count(distinct Fruit) from <urtable>select [type] from (select row_number() over(partition by [type] order by Fruit) as seq, * from <urtable>) twhere t.seq = @cnt
This is the sample data I used.declare @t table (Fruit varchar(100),[type] varchar(100))insert @tselect 'apple', 'granny'union all select 'apple', 'gala'union all select 'apple', 'delicious'union all select 'orange', 'granny'union all select 'orange', 'satsuma'union all select 'orange', 'tangerine'union all select 'banana', 'granny'union all select 'banana', 'jamaican'union all select 'banana', 'barbados'
quote:
Originally posted by aivoryuk
hisorry Im not sure I followquote:
Originally posted by DonAtWork
Very possible. First, normalize your database. Then you will see just how easy it is.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp