Skip to content

Instantly share code, notes, and snippets.

View spaztic1215's full-sized avatar

Jenny Kim spaztic1215

View GitHub Profile
@spaztic1215
spaztic1215 / export_cps_to_sku.sql
Created December 31, 2013 20:14
Export CPS data to SKU.csv
select sku.id as "skuId", sku, coalesce(merchant_detail_url, affiliate_detail_url, null) as "detail_url", coalesce(affiliate_buy_url, affiliate_detail_url) as "buy_url", price, EXTRACT(EPOCH FROM sku.created AT TIME ZONE 'UTC') as "skuCreated", EXTRACT(EPOCH FROM sku.updated AT TIME ZONE 'UTC') as "skuUpdated", sku.active as "skuActive",
product.id as "productId", product.name as "productName", image, product.description, category.name as "category", product.age, product.gender, EXTRACT(EPOCH FROM product.created AT TIME ZONE 'UTC') as "productCreated", EXTRACT(EPOCH FROM product.updated AT TIME ZONE 'UTC') as "productUpdated", product.active as "productActive",
merchant.id as "merchantId", merchant.name as "merchantName", EXTRACT(EPOCH FROM merchant.created AT TIME ZONE 'UTC') as "merchantCreated", EXTRACT(EPOCH FROM merchant.updated AT TIME ZONE 'UTC') as "merchantUpdated",
category.id as "categoryId"
from sku
join product on sku.product_id = product.id
join merchant on sku.merc