WITH t AS(
SELECT 'simon'NAME,100 a,200 b,300 c,400 d FROM dual
UNION ALL
SELECT 'angela',100,100,100,200 FROM dual
)
--不按name分组
SELECT NAME,a+b+c+d FROM t
--按name分组
SELECT NAME,Sum(a+b+c+d) FROM t GROUP BY NAME
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
SQL code
1.SELECT NAME,Sum(a+b+c+d) FROM a1 GROUP BY NAME
2.select * from a2 where exists(select 1 from (select max(age) as ages,min(salary) as salarys from
a2) z where z.ages=a2.age and z.salarys=a2.salary)
------解决方案-------------------- with as table()..创建临时表 rn=1,是先利用DENSE_RANK()函数按年龄倒序工资升序排名,取排名第一的资料 这些语法的东西LZ可自行查阅资料应该都很容易查到..
------解决方案-------------------- 晕,第一题很简单,没那么复杂吧?用不到SUM的,直接a+b+c+d不就可以了 select name,a+b+c+d from a;
题二: select name,age,salary from a where age=(select max(age) from a) and salary=(select min(salary) from a);