Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 24th, 2004, 10:14 AM
MiniMe83 MiniMe83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 MiniMe83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problems with SQL statement

Hi guys, I posted a similar thread to this on another forum however I've made some progress since. I want to be able to write the names of the 4 teams with the highest Points total to file. Any ideas? Im stuck on the SQL command.

The table is called League, field containing team names = Team, field containing points = Points.

Many thanks, David

[vb]Option Explicit

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Form_Load()

Set cn = New ADODB.Connection 'cnHome
Set rs = New ADODB.Recordset 'rsHome

Dim strFile As String
Dim sSQL As String

strFile = "yourdb.mdb"

sSQL = "SELECT * FROM League WHERE Points....."

cn.ConnectionString = strFile 'open the ADO connection and recordset
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open
cn.Properties("Jet OLEDB:Max Buffer Size") = 256

rs.Open sSQL, cn

'Do While Not rs.EOF

'Loop
'rs.MoveNext

End Sub

Private Sub cmdGet_Click()

Open App.Path + "/Retrieve.txt" For Output As #1

Print #1, rs("Team")

Close #1

End Sub

Private Sub Form_Unload(Cancel As Integer)

'Close connection and recordset and destroy them
rs.Close
Set rs = Nothing

cn.Close
Set cn = Nothing

End Sub[/vb]

Reply With Quote
  #2  
Old February 25th, 2004, 09:02 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,246 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 17 h 3 m 28 sec
Reputation Power: 1055
select top 4 team,sum(points) as totalpoints
from league
group by team
order by sum(points) desc
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Problems with SQL statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT