Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
951 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 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...