/*
Productid name age email mobile
---------------------------------------------
1 long 88 test@gmail.com 13000000000
2 LZ
Merge execution steps: Convert rows into columns, group and determine the number of rows, and add columns after in. The column value is the value after applying the aggregate function.
1. Implicit grouping (all columns in the left input are grouped by fieldvalue and fieldid to obtain all rows)
2. Isolation value (use case for each column in The in clause)WhenFieldid = <target column>ThenFieldvalueEnd)
3. Apply aggregate and function (for the case clause in 2, apply aggregate and function, Min here)
*/
SelectProductid,Min([1]) [name],Min([2]) age,Min([3]) email,Min([4]) mobile
FromProdfieldvalue
Partition (Min(Fieldvalue)ForFieldidIn([1], [2], [3], [4])AsD
Group ByProductid
/*
Result:
Productid fieldvalue filedid
----------------------------------------
1 long 1
1 88 2
1 test@gmail.com.com 3
1 1300000000 4
2 LZ 1
Unsynchronized: perform the following steps: convert a column into a row, copy the rows in the uncommitted left input, and enter the number of rows in the middle of each row in the left input,
Add a new column. The column name is the value after the for column. assign values to each row of the column in the order of the in values. filter out the rows whose new column value is null.
1. Generate a copy
2. Isolate target column values
3. filter out rows with null values
*/
Select*From(
SelectProductid,Min([1]) [1],Min([2]) [2],Min([3]) [3],Min([4]) [4]
FromProdfieldvalue
Partition (Min(Fieldvalue)ForFieldidIn([1], [2], [3], [4])AsD
Group ByProductid) T
Unregister (fieldvalueForFiledidIn([1], [2], [3], [4])AsTT