在sql查询中计算 [英] calculation in sql query

查看:193
本文介绍了在sql查询中计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有一个学生出勤专栏。其中学生可以参加10个学生。



栏目如下: -



Att(10)

5

8

7



i需要将此出勤率转换为10个使用sql查询的20个。

我该怎么办

解决方案

试试:

  SELECT  [Att( 10 )] *  2  < span class =code-keyword> AS  [Att( 20 )]  FROM  MyTable 


假设您的出席率为10.现在您要将其转换为X(这是20个)。尝试以下查询。只需用任意数字替换X.

  SELECT  [Att( 10 )] *(X / 10) AS  [Att(X)]  FROM  MyTable。



请记住,X只是您必须在此查询中将其替换为您想要的任何内容(例如,20,50,100)等等)。上面的查询只是粗略的表示。 X必须用数字替换。


Sir, i have a student attendance column. in which student get attendance out of 10.

column look like :-

Att(10)
5
8
7

i need to convert this attendance out of 10 to out of 20 using sql query.
how can i do it

解决方案

Try:

SELECT [Att(10)] * 2 AS [Att(20)] FROM MyTable


Suppose you have attendance out of 10. Now you want to convert it to out of X (Here is out of 20). Try following Query. Just replace X with any number whatever you want.

SELECT [Att(10)] * (X/10) AS [Att(X)] FROM MyTable.


Keep in mind that X is just place that you have to replace it in this query with anything that you want (ex. 20, 50, 100 etc). Above query is just rough representation. X must be replaced with a number.


这篇关于在sql查询中计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆