-
sql query construction help
hi guys.
I need to construct a query to get the following data.
select (param1, param2, param3) WHERE Param2 = (Max(param2)-1)
much simplified, of course. but how can i do this with a SQL query?
-Jon
Visual Basic 6.0
Microsoft Access 2003
-
ok and just realized, not EXACTLY -1. but like -1 ± .3
-Jon
Visual Basic 6.0
Microsoft Access 2003
-
You don't mention what database you're using, but you might try this:
SELECT (param1, param2, param3) FROM TableName
WHERE param2 = (SELECT Max(param2) - 1 FROM TableName)
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
 Originally Posted by Phil Weber
You don't mention what database you're using, but you might try this:
SELECT (param1, param2, param3) FROM TableName
WHERE param2 = (SELECT Max(param2) - 1 FROM TableName)
Access 03
is there a way i can do it -1 plus or minus 0.3 ?
-Jon
Visual Basic 6.0
Microsoft Access 2003
-
got it. thanks Phil.
this is for my application, but maybe someone else would need something similar
Code:
SELECT DISTINCT [Table_Name].[Param1], [Table_Name].[Param2], [Table_Name].[Param3], [Table_Name].[Param4], [Table_Name].[Param5], [Table_Name].[Param6], [Table_Name].Param7, [Table_Name].Param8, [Table_Name].Param9, [Table_Name].Param10, [Table_Name].[Param11]
FROM Table_Name
WHERE (
((([Table_Name].[Param3])=3.3) AND (([Table_Name].[Param4])=0.2) AND (([Table_Name].[Param5])=100) AND (([Table_Name].[Param6])=4900) AND (([Table_Name].Param7)="CWRF") AND (([Table_Name].Param8)="AN1-RA1") AND (([Table_Name].Param9)="AN1-RA1") AND (([Table_Name].[Param11])=25) AND ([Table_Name].Param10 Like "*5")) AND
([Table_Name].[Param2])>(
SELECT (MAX([Table_Name].[Param2])-1.01) FROM [Table_Name]
WHERE ((([Table_Name].[Param3])=3.3) AND
(([Table_Name].[Param4])=0.2) AND
(([Table_Name].[Param5])=1) AND
(([Table_Name].[Param6])=4) AND
(([Table_Name].Param7)="CW") AND
(([Table_Name].Param8)="this") AND
(([Table_Name].Param9)="this") AND
(([Table_Name].[Param11])=25)
AND ([Table_Name].Param10 Like "*5")
))
AND
(([Table_Name].[Param2])<(SELECT (MAX([Table_Name].[Param2])-0.99) FROM [Table_Name]
WHERE (
(([Table_Name].[Param3])=3.3) AND
(([Table_Name].[Param4])=0.2) AND
(([Table_Name].[Param5])=1) AND
(([Table_Name].[Param6])=4) AND
(([Table_Name].Param7)="CW") AND
(([Table_Name].Param8)="this") AND
(([Table_Name].Param9)="this") AND
(([Table_Name].[Param11])=25) AND
([Table_Name].Param10 Like "*5")
) ))
);
-Jon
Visual Basic 6.0
Microsoft Access 2003
Similar Threads
-
By vaibhavpingle in forum Java
Replies: 0
Last Post: 11-30-2006, 05:58 AM
-
By lightningtechie in forum Database
Replies: 1
Last Post: 02-07-2006, 08:34 AM
-
By Daniel Reber in forum VB Classic
Replies: 0
Last Post: 09-16-2002, 02:50 PM
-
By Ken D. in forum VB Classic
Replies: 2
Last Post: 09-03-2002, 11:25 PM
-
By Jeff Johnson in forum Database
Replies: 3
Last Post: 04-30-2001, 02:42 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks