数据库工资总和怎么算

数据库工资总和怎么算,第1张

应发工资的总额方法:1. 语法形式:select 列名 | expr | agfunc(列名) [[, 列名 | expr | agfunc(列名)] ... ] from 表名1 [, 表名2 ... ] [where 检索条件]①expr:常量,列名,由常量、列名、特殊函数及算术运算符构成的算术运算式 ②agfunc:聚集函数,如求平均、求和等【示例1】求有差额(差额>0)的任意两位教师的薪水差额:select T1.Tname as TR1, T2.Tname as TR2, T1.Salary - T2.Salary from Teacher T1, Teacher T2 where T1.Salary >T2.Salary【示例2】依据学生年龄求学生的出生年份,当前是2019年:select S.S#, S.Sname, 2019 - S.Sage + 1 as Syear from Student S

/*按照你的要求,比如:6个大类:A,B,C,D,E,F

A类下面有小类A1,A2,单价分别为1,2

B类下面有小类B1,B2,单价分别为3,4

C类下面有小类C1,C2,单价分别为5,6

D类下面有小类D1,D2,单价分别为7,8

E类下面有小类E1,E2,单价分别为9,10

F类下面有小类F1,F2,单价分别为11,12

*/

--设计一个基础配置表:

create table a(

id varchar2(20),

superid varchar2(20),

discription varchar2(20),

money number(10))

-- 插入数据

insert into a(id,superid,discription,money)VALUES('A1','A','小类A1',1)

insert into a(id,superid,discription,money)VALUES('A2','A','小类A2',2)

insert into a(id,superid,discription,money)VALUES('B1','B','小类B1',3)

insert into a(id,superid,discription,money)VALUES('B2','B','小类B2',4)

insert into a(id,superid,discription,money)VALUES('C1','C','小类C1',5)

insert into a(id,superid,discription,money)VALUES('C2','C','小类C2',6)

insert into a(id,superid,discription,money)VALUES('D1','D','小类D1',7)

insert into a(id,superid,discription,money)VALUES('D2','D','小类D2',8)

insert into a(id,superid,discription,money)VALUES('E1','E','小类E1',9)

insert into a(id,superid,discription,money)VALUES('E2','E','小类E2',10)

insert into a(id,superid,discription,money)VALUES('F1','F','小类F1',11)

insert into a(id,superid,discription,money)VALUES('F2','F','小类F2',12)

-- 例如:输入工序名"小类C1"查找其单价的sql语句:

SELECT money FROM a WHERE a.discription = '小类C1'

-- 例如:输入工序名"小类C1"的数量为"100",可以直接计算出工资的sql语句:

SELECT money*100 FROM a WHERE a.discription = '小类C1'

-- 希望对你有帮助


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6685715.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存