Programming Forums
User Name Password Register

RSS Feed

Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 18th, 2012, 1:14 AM   #1
Join Date: Feb 2012
Posts: 2
Rep Power: 0 alexabc123fgh is on a distinguished road
[split] database

So I know this is a pretty dumb question, however (as the rather lengthily title says) I would like to know how do the following:

I have a table like this:

ID Foo Bar Blagh
1 10 20 30
2 10 5 1
3 20 50 40
4 20 75 12
I want to group by Foo, then pull out rows with minimum Bar, i.e. I want the following:

ID Foo Bar Blagh
2 10 5 1
3 20 50 40
I can't for the life of me work out the correct SQL to retrieve this. I want something like:

SELECT ID, Foo, Bar, Blagh
FROM Table
However this clearly doesn't work as that is completely invalid HAVING syntax and ID, Foo, Bar and Blagh are not aggregated.

What am I doing wrong?
alexabc123fgh is offline   Reply With Quote


« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Connection With PHP kvdhanush PHP 0 Feb 3rd, 2011 7:33 AM and Access database integration 47states Visual Basic .NET 4 Jan 22nd, 2011 12:09 AM
Storing BLOBs in a database - problem jonyzz Other Programming Languages 8 Jan 31st, 2007 5:38 AM
Using ODBC to connect to a remote database in a C program bigi C++ 1 Mar 8th, 2005 4:19 PM

DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC