Difference between revisions of "Fraud Book"

From Bitnami MediaWiki
Jump to navigation Jump to search
Line 9: Line 9:
  
 
p. 136
 
p. 136
 +
 
<font face="Courier New" size="2">
 
<font face="Courier New" size="2">
 
<font color = "blue">WITH</font>&nbsp;<font color = "maroon">table_of_how_many_times_each_combination_of_zip_and_city_appeared</font>
 
<font color = "blue">WITH</font>&nbsp;<font color = "maroon">table_of_how_many_times_each_combination_of_zip_and_city_appeared</font>

Revision as of 17:58, 10 March 2022

Style Guides

p. 136

WITH table_of_how_many_times_each_combination_of_zip_and_city_appeared
     AS (SELECT zipcode,city,Count(*) AS count_orders
         FROM   shipping_addresses
         GROUP  BY 1,2)
SELECT city,Percent_rank()
              OVER (
                partition BY zipcode
                ORDER BY count_orders) AS PctRank
ORDER  BY pctrank ASC;