How to multiply values using SQL

后端 未结 4 1086
遥遥无期
遥遥无期 2021-01-13 02:03

Ok so I\'m working on my homework and am having trouble figuring out how to multiply with SQL and how to get this to order correctly.

I am supposed to \"create a que

相关标签:
4条回答
  • 2021-01-13 02:54

    Why are you grouping by? Do you mean order by?

    SELECT player_name, player_salary, player_salary * 1.1 AS NewSalary
    FROM players
    ORDER BY player_salary, player_name;
    
    0 讨论(0)
  • 2021-01-13 02:54

    You don't need to use GROUP BY but using it won't change the outcome. Just add an ORDER BY line at the end to sort your results.

    SELECT player_name, player_salary, SUM(player_salary*1.1) AS NewSalary
    FROM players
    GROUP BY player_salary, player_name;
    ORDER BY SUM(player_salary*1.1) DESC
    
    0 讨论(0)
  • 2021-01-13 02:55

    Here it is:

    select player_name, player_salary, (player_salary * 1.1) as player_newsalary
    from player 
    order by player_name, player_salary, player_newsalary desc
    

    You don't need to "group by" if there is only one instance of a player in the table.

    0 讨论(0)
  • 2021-01-13 03:05

    Why use GROUP BY at all?

    SELECT player_name, player_salary, player_salary*1.1 AS NewSalary
    FROM players
    ORDER BY player_salary DESC
    
    0 讨论(0)
提交回复
热议问题