About 297,000 results
Open links in new tab
  1. How to do simple math in an SQL SELECT query? - Stack Overflow

    How to do simple math in an SQL SELECT query? Asked 13 years, 5 months ago Modified 13 years, 5 months ago Viewed 34k times

  2. Do math in MySQL from SELECT - Stack Overflow

    Sep 24, 2014 · You can't use aliases that are defined in the SELECT clause to calculate other columns that are also in the same SELECT clause. You have at least three options: Repeat the subquery …

  3. Writing a Mathematical Formula in SQL? - Stack Overflow

    I have these tables: users, comments, ratings, and items I would like to know if it is possible to write SQL query that basically does this: user_id is in each table. I'd like a SQL query to count

  4. What are the pros and cons of performing calculations in sql vs. in ...

    Sep 22, 2011 · I think that a good rule of thumb is: don't bring back from SQL server rows of data you don't ultimately need. For example, if you have to perform aggregate operations, they likely belong in …

  5. Multiplying Two Columns in SQL Server - Stack Overflow

    How can I perform operations such as Multiplying and Subtracting two columns in SQL Server? Payment PK - PaymentID FK - PaymentTypeID FK - OccupiedApartmentID **- InitalPayment - …

  6. How to use aliases in math operators in SQL? - Stack Overflow

    Feb 29, 2016 · 1 You can't use aliases at the same level they are defined -- you need to put the alias definition in a subquery. But, you don't need aliases, because SQL has the AVG() function:

  7. perform math on multiple SELECT results in SQL

    May 9, 2015 · Similar to this question How does one perform math on multiple SELECT results? Cant make mine work. I want to determine the % of Shipments that are were sent on time. To do so, I …

  8. MS SQL Server - Use Calculated Field of SELECT statement

    Feb 14, 2018 · If you look at SELECT (Transact-SQL) you'll note that the SELECT is the 8th part of the query to be processed. This means only ORDER BY is going to be able to reference a column's …

  9. How to calculate math formula in SQL? - Stack Overflow

    Jul 28, 2022 · This is my SQL table structure for example: Is there a way to calculate the final result in Result column. The result should be 210, 1190, -630 respectively. I prefer non-dynamic query, so …

  10. sql - How to do addition and division of aliased columns in a query ...

    Jan 27, 2012 · 5 I am using SQL Server 2008. I am trying to do some basic math in some basic queries. I need to add up wins, losses, total, and percentages. I usually ask for the raw numbers and then do …