Re: SQL Задача 35

From Martin Movsisyan, 5 Months ago, written in SQL, viewed 164 times. This paste is a reply to SQL Задача 31 from Martin Movsisyan - view diff
URL http://codebin.org/view/7c9040fc Embed
Download Paste or View Raw
  1. SELECT CAST(DATE_TRUNC('month', order_date) AS DATE) AS MONTH
  2.        ,COUNT(DISTINCT customer_id) AS customers_this_month
  3.        ,SUM(COUNT(DISTINCT customer_id)) OVER (ORDER BY CAST(DATE_TRUNC('month', order_date) AS DATE)) AS total_customers
  4.        ,ROUND(COUNT(DISTINCT customer_id)/SUM(COUNT(DISTINCT customer_id)) OVER (ORDER BY CAST(DATE_TRUNC('month', order_date) AS DATE))*100,2) AS conversion
  5. FROM northwind.orders
  6. WHERE CAST(DATE_TRUNC('month', order_date) AS DATE) BETWEEN '1996-07-01' AND '1998-05-31'
  7. GROUP BY CAST(DATE_TRUNC('month', order_date) AS DATE)
  8. ORDER BY CAST(DATE_TRUNC('month', order_date) AS DATE)

Replies to Re: SQL Задача 35 rss

Title Name Language When
Re: Re: SQL Задача 35 Martin Movsisyan sql 5 Months ago.

Reply to "Re: SQL Задача 35"

Here you can reply to the paste above