Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 4 of 4 total |
MAX and MIN in an Expression |
Mon, Feb 24 2014 12:03 PM | Permanent Link |
jframe | I want to do something like this:
SELECT WSN, MAX(BASE) - MIN(TOP)FROM PERFS GROUP BY WSN But I keep getting an error stating "Aggregate functions cannot be used within an expression" Any thoughts? |
Mon, Feb 24 2014 6:08 PM | Permanent Link |
John Easley | You might have to do this in two swoops..as the error indicates, you cannot use aggregate functions within expressions..
SELECT WSN MAX(BASE) as MaxBase, MIN(TOP) as MinTop INTO memory FirstPass FROM PERFS GROUP BY WSN ; SELECT (MaxBase - MinTop) as MyCalc FROM memory FirstPass Note, you may need to use memory\Firstpass depending on your version of DBISAM. John jframe wrote: I want to do something like this: SELECT WSN, MAX(BASE) - MIN(TOP)FROM PERFS GROUP BY WSN But I keep getting an error stating "Aggregate functions cannot be used within an expression" Any thoughts? |
Wed, Feb 26 2014 11:32 AM | Permanent Link |
jframe | This works. Thanks!
John Easley wrote: You might have to do this in two swoops..as the error indicates, you cannot use aggregate functions within expressions.. SELECT WSN MAX(BASE) as MaxBase, MIN(TOP) as MinTop INTO memory FirstPass FROM PERFS GROUP BY WSN ; SELECT (MaxBase - MinTop) as MyCalc FROM memory FirstPass Note, you may need to use memory\Firstpass depending on your version of DBISAM. John jframe wrote: I want to do something like this: SELECT WSN, MAX(BASE) - MIN(TOP)FROM PERFS GROUP BY WSN But I keep getting an error stating "Aggregate functions cannot be used within an expression" Any thoughts? |
Fri, Feb 28 2014 4:53 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << I want to do something like this: SELECT WSN, MAX(BASE) - MIN(TOP)FROM PERFS GROUP BY WSN But I keep getting an error stating "Aggregate functions cannot be used within an expression" >> Is this DBISAM 4.x, or earlier ? You should be able to use aggregate functions in expressions in later 4.x versions. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |