sql有什么变化? [英] what is the change in sql?

查看:86
本文介绍了sql有什么变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的数据库表中的
将groupname分别为'Permanent','Apprentice','Contract','Act Apprentice'作为每个部门的名称。 A,G1,B,C,G2有5班。









结果如下表所示。





deptId deptName 9 10 11 13 groupName A G1 BC G2

------ -------- --- --- --- --- ---------- ---- --- --- - - ---

8医生2 2 0 0永久0 1 0 0 1

8医生2 2 0 0学徒0 0 0 0 1

10 Pharmasy 2 0 0 0 Permanent 0 2 0 0 0

11参加者4 1 0 0永久0 0 2 1 0

11参加者4 1 0 0学徒1 0 0 0 0











但是我想要结果表如下,







deptId deptName 9 10 11 13 groupName A G1 BC G2

------ ----- --- --- --- --- --- ---------- ---- --- --- ---- ---

8医生2 2 0 0永久0 1 0 0 1

8医生2 2 0 0学徒0 0 0 0 1

8医生2 2 0 0合同0 0 0 0 0

8位医生2 2 0 0 Act Apprentice 0 0 0 0 0



10 Pharmasy 2 0 0 0 Permanent 0 2 0 0 0

10 Pharmasy 2 0 0 0学徒0 0 0 0 0

10 Pharmasy 2 0 0 0合同0 0 0 0 0

10 Pharmasy 2 0 0 0 Act Apprentice 0 0 0 0 0



11参加者4 1 0 0永久0 0 2 1 0

11参加者4 1 0 0学徒1 0 0 0 0

11参加者4 1 0 0合同0 0 0 0 0

11参加者4 1 0 0 Act Apprentice 0 0 0 0 0





是每个groupname的部门详细信息。如何获得上述结果?

Hi,

in my db table have groupname as 'Permanent','Apprentice','Contract','Act Apprentice' for each department.each groupname have 5 shift as A,G1,B,C,G2.




result as below table.


deptId deptName 9 10 11 13 groupName A G1 B C G2
------ -------- --- --- --- --- ---------- ---- --- --- ---- ---
8 Doctors 2 2 0 0 Permanent 0 1 0 0 1
8 Doctors 2 2 0 0 Apprentice 0 0 0 0 1
10 Pharmasy 2 0 0 0 Permanent 0 2 0 0 0
11 Attenders 4 1 0 0 Permanent 0 0 2 1 0
11 Attenders 4 1 0 0 Apprentice 1 0 0 0 0





but i want the result table as below,



deptId deptName 9 10 11 13 groupName A G1 B C G2
------ -------- --- --- --- --- ---------- ---- --- --- ---- ---
8 Doctors 2 2 0 0 Permanent 0 1 0 0 1
8 Doctors 2 2 0 0 Apprentice 0 0 0 0 1
8 Doctors 2 2 0 0 Contract 0 0 0 0 0
8 Doctors 2 2 0 0 Act Apprentice 0 0 0 0 0

10 Pharmasy 2 0 0 0 Permanent 0 2 0 0 0
10 Pharmasy 2 0 0 0 Apprentice 0 0 0 0 0
10 Pharmasy 2 0 0 0 Contract 0 0 0 0 0
10 Pharmasy 2 0 0 0 Act Apprentice 0 0 0 0 0

11 Attenders 4 1 0 0 Permanent 0 0 2 1 0
11 Attenders 4 1 0 0 Apprentice 1 0 0 0 0
11 Attenders 4 1 0 0 Contract 0 0 0 0 0
11 Attenders 4 1 0 0 Act Apprentice 0 0 0 0 0


that is department details for each groupname.How to get the above result?

推荐答案

你可以这样做:

You can do :
select * from ( your original query here ) as t order by t.deptId 



并将原始查询放在括号中而不是文本中(因为你没有在你的问题中提供查询)


and put your original query in the parenthesis instead of the text (since you have not supplied the query in your question)


这篇关于sql有什么变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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