Select group number for distinct rows based on two columns

  • Follow


Hi,
I have a problem, need to number the distinct rows based on two columns.
Eg, I have the table like this:

ID     FirstName       LastName
=================================
1       Leuis            Red
2       Red              Leuis
3       Leuis            Kit
4       Jane             Fonda
5       James            White
6       White            James

I need a query to get the result like this:

Group       Name
=================
1           Leuis
1           Red
1           Kit
2           Jane
2           Fonda
3           James
3           White

Please help me,
Thanks
Shaini.



Submitted via EggHeadCafe - Software Developer Portal of Choice 
Dr. Dotnetsky's Cool .Net Tips & Tricks #21
http://www.eggheadcafe.com/tutorials/aspnet/bc6fa874-2326-4bd7-a097-dd7f54909272/dr-dotnetskys-cool-net.aspx
0
Reply shaini 1/14/2010 8:41:04 AM

Hi Shaini,

     I am missing what rule(s) your are applying to transform the data from
the one form into the other.  On what basis does a name go into a particular
group number?

             Clifford Bass

shaini b wrote:
>Hi,
>I have a problem, need to number the distinct rows based on two columns.
>Eg, I have the table like this:
>
>ID     FirstName       LastName
>=================================
>1       Leuis            Red
>2       Red              Leuis
>3       Leuis            Kit
>4       Jane             Fonda
>5       James            White
>6       White            James
>
>I need a query to get the result like this:
>
>Group       Name
>=================
>1           Leuis
>1           Red
>1           Kit
>2           Jane
>2           Fonda
>3           James
>3           White
>
>Please help me,
>Thanks
>Shaini.
>
>Submitted via EggHeadCafe - Software Developer Portal of Choice 
>Dr. Dotnetsky's Cool .Net Tips & Tricks #21
>http://www.eggheadcafe.com/tutorials/aspnet/bc6fa874-2326-4bd7-a097-dd7f54909272/dr-dotnetskys-cool-net.aspx

-- 
Message posted via http://www.accessmonster.com

0
Reply Clifford 1/14/2010 4:53:34 PM


1 Replies
589 Views

(page loaded in 1.266 seconds)

Similiar Articles:
















7/28/2012 10:58:46 AM


Reply: