Print Page | Close Window

Math with columns in SQL??

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10672
Printed Date: 31 March 2026 at 1:54pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Math with columns in SQL??
Posted By: FLATLINE
Subject: Math with columns in SQL??
Date Posted: 31 May 2004 at 4:35am

Hello,

I need to open a SQL query and order it by the multiplication of two fields. I couldn't do it using the string below, and I don't want to add an extra column to hold the results. Is this possible? How?

strSQL = "SELECT * FROM table ORDER BY field1*field2 DESC;"

Thanks.



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Replies:
Posted By: Mart
Date Posted: 31 May 2004 at 4:36am
Is this access or MSSQL?


Posted By: FLATLINE
Date Posted: 31 May 2004 at 4:38am
MSAccess 2000

-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: Phat
Date Posted: 31 May 2004 at 6:43am
Try

SELECT Table1.*, [Table1]![f1]*[Table1]![f2] AS Total
FROM Table1
ORDER BY [Table1]![f1]*[Table1]![f2];



Posted By: FLATLINE
Date Posted: 31 May 2004 at 9:42am
why do you use brackets and an exclamation mark? And if you're querying the result as Total then why do you still order the recordset using the multiplication?

-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: Phat
Date Posted: 31 May 2004 at 8:35pm
That sql was built in access with the query builder. There may be other ways to do it but that is what access gives as an output.



Posted By: FLATLINE
Date Posted: 31 May 2004 at 9:28pm
It works great. Thanks. 

-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net