SELECT DISTINCT ON (asin) asin, price, reviews, raing
(SELECT array_agg(j) FROM (SELECT DISTINCT ON (j.asin) j FROM jsonb_populate_recordset(NULL::t_best_asin_ranking_2, '[{
"asin":"B06XH9FNH1",
"price": 1.5,
"rating": 1.5,
"reviews": 1
}]') j ORDER BY j.asin) r);
package main
func main() {
var str strType
str.Temp()
}
type strType string
func (s strType) Temp() {
}
UPDATE data_table
SET
jsonb_column = jsonb_set(jsonb_column, '{phones}', jsonb_build_array(jsonb_column->'phone'))
WHERE
(NOT (jsonb_column ? 'phones')) AND (jsonb_column ? 'phone')
package main
import (
"encoding/json"
"fmt"
)
type Resp struct {
R struct {
Items []int
}
}
func main() {
response := []byte(`{"r":{"max":900,"items":[1,3,5,7,3,1,7]}}`)
r := Resp{}
json.Unmarshal(response, &r)
for i := range r.R.Items {
fmt.Println(i)
}
}
type Resp struct {
R struct {
Max int `json:"max"`
Items []int `json:"items"`
} `json:"r"`
}