Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
955 views
in Technique[技术] by (71.8m points)

mysql - Dynamically creating columns from row data using Select in Bigquery

Background

I want to rename my case statement in sql select statement dynamically.

Eg:

SELECT (case when id= x.id then x.sums end) x.id as (select id,count(*) sums from table group by id) x

what i want the output is list of columns created ,with Labels as distinct id's from "id" column.

However,this variable x.id is not dynamically outputing values,rather i get output a single column x.id.

Eg:

Columns in table...

id---c1----c2


1----x1---x2

2----x2----x3

3----x4----x5

columns expected after running query...

1-----2----3


but actual o/p column is::

x.id


Query Any ideas,how to generate columns dynamically using select query,please correct me ,if i am wrong.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...