What is a "Foreword" to a blog?
Group by issues
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• GYXU
  • Ñîîáùåñòâà
• Talxy Chat
• Horoscope
• Online
 
Register!

GYXU > Kites, widsurfing, waterski > Group by issues 29 April 2005 04:32:36

  Recent blog posts: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Ìîäåðàòîð:

Group by issues

Geronimo 28 April 2005 04:54:06
 I'm having a brain fade, and hope someone can help out.

Consider a table as bolow.
ID CODE VALUE
-------------------­--
1 a 1
2 a 2
3 b 1

I want the row with the highest 'value' of each 'code'

I need the whole row (all fields), and although the ID field is unique
in this example, it isn't in the real life table, removing the ability
to do a subquery on ID.

Here's a script to build the example table.

Thanks,
Ger

--=================­====================­=====
DROP table #temp

SELECT 1 AS 'id', 'a' AS code, 1 AS value
INTO #temp
UNION
SELECT 2, 'a', 2
UNION
SELECT 3, 'b', 1

SELECT * from ##temp
--=================­====================­=====
Add comment
Geronimo 28 April 2005 05:15:45 permanent link ]
 Bugger, wrong group. I have a habit of doing this.
Anyhow, problem's sorted.

Ger

In article <MPG.1cdad12d8d43f9­e5989685@freenews.ii­net.net.au>, a@b.c
says...> I'm having a brain fade, and hope someone can help out.>
Consider a table as bolow.> ID CODE VALUE> -------------------­--> 1 a 1> 2 a 2> 3 b 1>
I want the row with the highest 'value' of each 'code'>
I need the whole row (all fields), and although the ID field is unique > in this example, it isn't in the real life table, removing the ability > to do a subquery on ID.>
Here's a script to build the example table.>
Thanks, > Ger>
--=================­====================­=====> DROP table #temp>
SELECT 1 AS 'id', 'a' AS code, 1 AS value> INTO #temp> UNION> SELECT 2, 'a', 2> UNION> SELECT 3, 'b', 1>
SELECT * from ##temp> --=================­====================­=====>
Add comment
GWood 28 April 2005 22:29:10 permanent link ]
 Scary thing is, I was about to respond.

I peruse a couple of SQL related groups as well as windsurfing and biking
groups on a pretty regular basis. Was just putting on my "SQL Hat" when I
realized this was rec.windsurfing.

Geekdom is easily transferable between interests...


"Geronimo" <a@b.c> wrote in message
news:MPG.1cdad63a9a­f810df989686@freenew­s.iinet.net.au...> Bugger, wrong group. I have a habit of doing this.> Anyhow, problem's sorted.>
In article <MPG.1cdad12d8d43f9­e5989685@freenews.ii­net.net.au>, a@b.c> says...> > I'm having a brain fade, and hope someone can help out.> >
Consider a table as bolow.> > ID CODE VALUE> > -------------------­--> > 1 a 1> > 2 a 2> > 3 b 1> >
I want the row with the highest 'value' of each 'code'> >
I need the whole row (all fields), and although the ID field is unique> > in this example, it isn't in the real life table, removing the ability> > to do a subquery on ID.> >
Here's a script to build the example table.> >
Thanks,> > Ger> >
--=================­====================­=====> > DROP table #temp> >
SELECT 1 AS 'id', 'a' AS code, 1 AS value> > INTO #temp> > UNION> > SELECT 2, 'a', 2> > UNION> > SELECT 3, 'b', 1> >
SELECT * from ##temp> > --=================­====================­=====> >


Add comment
The Dog 29 April 2005 04:32:36 permanent link ]
 In article <MPG.1cdad12d8d43f9­e5989685@freenews.ii­net.net.au>, a@b.c
says...> I'm having a brain fade, and hope someone can help out.

It's just a guess, but I'm guessing a software group might be more
help. Though there are a lot of engineering types here.

Dog
--
http://www.mariner-­sails.com
http://www.thedogho­use.net
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
respect your talk pals, avoid using obscene language, typing entire messages in CAPS, posting buy/sell ads or violating netiquette or the RF Criminal Code..


GYXU > Kites, widsurfing, waterski > Group by issues 29 April 2005 04:32:36

see also:
Can you putt this well?
Ruling on Ball Hitting Manmade object
pass tests:
see also:
http://demish.gyxu.com/i/temp/2/128...
...
...

  Copyright © 2001—2009 GYXU
Idea: Miñhael Monashev
See Help and FAQ in the community support.gyxu.com.
Write in the community about the bugs you have noticedbugs.gyxu.com.
Write your offers and comments in the communities suggest.gyxu.com.
Information for parents.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .