且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转置查询输出

更新时间:2023-11-18 22:07:46

上面的任何建议..我需要完成一份报告吗?
Any suggestions for above.. i need to complete one report?


我不知道你在做什么。我不知道你是如何从样本数据中得到你的结果的。
I have no idea what you''re trying to do. I don''t see how you get to your results from your sample data.


好的..让我解释一下......


我想输出并不是很难理解..现在我的要求是将列更改成行..


现在查询输出是


id" 年龄

" 1" 0

" 1" 11

" 2" 0

" 2" 30

" 3" 0

" 3" 1

" 4" " 0"

" 4" 1

" 5" 0

" 5" 1


两列一个用于ID,另一列用于AGE ..现在我的要求是这样的......

ID 1 2 3 4 5

年龄0 0 0 0 0

年龄11 30 0 0 0


正常输出如果你看到那里每个ID都有两行。例如ID 1有两个值0和11.在我的要求中,ID应该是列,相关的AGE应该是行,因此对于ID 1,将有两行,一行包含值0,另一行11
> @Rabbit


感谢您的回复..我认为现在的要求应该是明确的..


此致,

RP
Okay.. let me explain a bit more..

I suppose output is not much difficult to understand.. now my requirement is to change column into rows..

right now query output is

id" "age"
"1" "0"
"1" "11"
"2" "0"
"2" "30"
"3" "0"
"3" "1"
"4" "0"
"4" "1"
"5" "0"
"5" "1"

Two columns one is for ID and another is for AGE.. now my requirement is something like this...
ID 1 2 3 4 5
AGE 0 0 0 0 0
AGE 11 30 0 0 0

In normal output if you see there are two rows for each ID. e.g. ID 1 has two values 0 and 11. In my requirement ID(s) should be column and related AGE should be rows, hence for ID 1 there would be two rows one containing value 0 and the other 11

@Rabbit

Thanks for the reply.. I think now the requirement should be clear..

Regards,
RP