Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

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 12th, 2006, 03:53 PM
grantfullen grantfullen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 6 grantfullen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 47 sec
Reputation Power: 0
Send a message via MSN to grantfullen Send a message via Yahoo to grantfullen
SQL Statments,Ado, Access Help

hello I am haveing a small problem with some Sql statments. I have access database named 'NightCert'. i have a table
named' Info'. there is a cell named 'Points' . I need to look through all the records of 'Points' and see wich record has the most points in it. I am trying to do that here
AdoQuery1.Close;
AdoQuery1.SQL.Clear;
AdoQuery1.sql.Add('select * from Info where Points=(Select Max(Points) from Info= aram1') ;
AdoQuery1.Parameters.ParseSQL(Adoquery1.SQL.Text, True);
AdoQuery1.Parameters.ParamByName('param1').Value:= AdoQuery1.SQL.Text;
Edit2.Text:= Adoquery1.SQL.Text;
AdoQuery1.Open;

Now the goal here is to find the record with the max points and dispaly the Name/Farm cell text in a edit.
Thanks for any help.
Grant

Reply With Quote
  #2  
Old February 15th, 2006, 09:24 AM
michaelm michaelm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 52 michaelm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 49 m 33 sec
Reputation Power: 3
Quote:
Originally Posted by grantfullen
hello I am haveing a small problem with some Sql statments. I have access database named 'NightCert'. i have a table
named' Info'. there is a cell named 'Points' . I need to look through all the records of 'Points' and see wich record has the most points in it. I am trying to do that here
AdoQuery1.Close;
AdoQuery1.SQL.Clear;
AdoQuery1.sql.Add('select * from Info where Points=(Select Max(Points) from Info= aram1') ;
AdoQuery1.Parameters.ParseSQL(Adoquery1.SQL.Text, True);
AdoQuery1.Parameters.ParamByName('param1').Value:= AdoQuery1.SQL.Text;
Edit2.Text:= Adoquery1.SQL.Text;
AdoQuery1.Open;

Now the goal here is to find the record with the max points and dispaly the Name/Farm cell text in a edit.
Thanks for any help.
Grant



I'm confused as to why you are passing a param ('param1') in your code above.... But to get the max value of a column for a particular table you can use the following:

"SELECT Name as 'Farm name', MAX(Points) as 'Farm points' FROM Info"


-Michael

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > SQL Statments,Ado, Access Help


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 6 hosted by Hostway
Stay green...Green IT