 * FROM bat_emails LIMIT 10;

-- Select all rows where the email sent_date predates the sales_transaction_date, order by the customer_id and limit the output to the first 22 rows

sqlda=# SELECT * FROM bat_emails WHERE sent_date < sales_transaction_date ORDER BY customer_id LIMIT 22;

-- Delete the rows where the bat_emails table which was sent before the 6-month mark prior to production

sqlda=# DELETE FROM bat_emails WHERE sent_date < '2016-04-10';

-- Delete the rows where the sent date is after the purchase date as they are not relevant to the sale

sqlda=# DELETE FROM bat_emails WHERE sent_date > sales_transaction_date;

-- Delete those rows where the difference between the transaction date and sent date exceeds 30, as we also only want those emails which were sent reasonably shortly before the scooter purchase

sqlda=# DELETE FROM bat_emails WHERE (sales_transaction_date-sent_date) > '30 days';

-- Examine the first 22 rows again ordered by customer_id by running the following query

sqlda=# SELECT * FROM bat_emails ORDER BY customer_id LIMIT 22;

-- Select the distinct value from the email_subject column to get a list of the different emails sent to the customers

sqlda=# SELECT DISTINCT(email_subject) FROM bat_emails;

-- Delete all records which have Black Friday in the email subject. These emails do not seem relevant to the sale of the Bat Scooter

sqlda=# DELETE FROM bat_emails WHERE position('Black Friday' in email_subject)>0;

-- Delete all rows where 25% off all EVs. It's a Christmas Miracle! and A New Year, And Some New EVs is in the email subject

sqlda=# DELETE FROM bat_emails WHERE position('25% off all EV' in email_subject)>0;
sqlda=# DELETE FROM bat_emails WHERE position('Some New EV' in email_subject)>0;

-- At this stage, we have our final dataset of emails sent to customers. Count the number of rows that are left in the sample by writing the following query

sqlda=# SELECT count(sales_transaction_date) FROM bat_emails;

-- We will now compute the percentage of emails that were opened relative to sales. Count the emails were opened by writing the following query

sqlda=# SELECT count(opened) FROM bat_emails WHERE opened='t'

-- Count the customers who received emails and made a purchase. We will determine this by counting the number of unique (or distinct) customers that are in the bat_emails table

sqlda=# SELECT COUNT(DISTINCT(customer_id)) FROM bat_emails;

-- Count the unique (or distinct) customers that made a purchase, by writing the following query

sqlda=# SELECT COUNT(DISTINCT(customer_id)) FROM bat_sales;

-- Calculate the percentage of customers who purchased a bat scooter after receiving an email

sqlda=# SELECT 396.0/6659.0 AS email_rate;

-- Limit the scope of our data to be all sales prior to 1st November 2016 and put the data in a new table called bat_emails_threewks

sqlda=# SELECT * INTO bat_emails_threewks FROM bat_emails WHERE sales_transaction_date < '2016-11-01';

-- Count the number of emails sent during this period

sqlda=# SELECT COUNT(opened) FROM bat_emails_threewks;

-- Count the number of emails opened in the first three weeks

sqlda=# SELECT COUNT(opened) FROM bat_emails_threewks WHERE opened='t';

-- Count the number of customers who received emails during the first three weeks of sales made a purchase using the following query

sqlda=# SELECT COUNT(DISTINCT(customer_id)) FROM bat_emails_threewks;

-- Calculate the percentage of customers who opened emails about the bat scooter made a sale in the first three weeks using the following query

sqlda=# SELECT 15.0/82.0 AS sale_rate;

-- Calculate how many unique customers we have in total throughout the first three weeks

sqlda=# SELECT COUNT(DISTINCT(customer_id)) FROM bat_sales WHERE sales_transaction_date < '2016-11-01';
Defending the Legacy: Did Cornwallis "Arrogantly Underestimate" Lafayette in the 1781 Virginia Campaign?
Did Cornwallis "Arrogantly Underestimate" Lafayette in the 1781 Virginia Campaign?
This quotation describes the 1781 Virginia campaign which ended in the surrender of Lord Cornwallis at Yorktown. Obviously, the authors are not impressed with Cornwallis’ record in Virginia. He is alternately accused of not regarding Lafayette’s army as a threat (underestimating), and then overestimating its effectiveness (wasting valuable time to rid himself of it) in a single sentence! These two charges are contradictory, but a this scathing critique of George III’s best fighting general justified?
In June of 1781, Lord Cornwallis had arrived in Virginia from South Carolina. Cornwallis had about 7,000 British and Hessian soldiers in his army. (1) Many of Cornwallis’ British soldiers were the elite of the British army in North America. The 23rd Royal Welsh Fusiliers, the 33rd Regiment, the 1st and 2nd Battalions of Light Infantry, and Banastre Tarleton’s British Legion were all fearsome troops. Each of these units had gained battlefield victories, despite being outnumbered by the rebels. These were true veterans. But the rest of Cornwallis’ army in Virginia was not comprised of second-rate troops. The 76th and 80th Regiments, though not as experienced in battle, would gain a victory at the Battle of Green Spring.
In Virginia, then, Cornwallis enjoyed both superiority of numbers and superiority of quality against Lafayette. He used this to carry out two lightning-fast raids against Charlottetown and Point of Fork. Lafayette was not able to counter these raids, and Cornwallis could be pardoned had he not regarded Lafayette’s army as a threat. But Cornwallis was too shrewd to do that.
Learning that Lafayette was following him towards the Virginia coastline, he set an ambush for him at Green Spring. In the ensuing battle, Lafayette’s force barely managed to escape defeat, thanks to Lafayette’s caution and timely darkness. The battle took place on July 6. Since Cornwallis fought and won against Lafayette, how can he be accused of failing to engage him in battle?
While Cornwallis did not arrogantly underestimate Lafayette, did he waste “valuable time” chasing him around Virginia? The assumption seems to be that had Cornwallis entrenched at Yorktown earlier, his fortifications would be more complete, the siege would have been slower, General Clinton would have sent British reinforcements from New York City, and Yorktown might not have been captured by Washington and Rochambeau.
Firstly, this is a precarious chain of events. There are no guarantees that more time entrenching would have changed the outcome of the battle. Had Clinton sent British reinforcements, they would likely have been defeated by the powerful fleet of Admiral de Grasse, prowling in the Chesapeake Bay with his French fleet.
Secondly, Cornwallis was hampered by contradictory orders from his superior, General Clinton. This resulted in a waste of time in marches and counter-marches around Virginia. Clinton and Cornwallis had different ideas on how to win the war. Clinton believed in fortifying key positions; Cornwallis preferred finding and defeating rebel armies.
In conclusion: did Cornwallis’ character faults doom him to defeat at Yorktown? Certainly not. Cornwallis was a wise general—probably the best Britain had in the American Revolution. His actions in the Virginia campaign against Lafayette were wise, not hampered by arrogant underestimation.
For more about the 1781 Campaign and the siege of Yorktown, check out my lecture: “A Providential View of the Battle of Yorktown.” It is available at: http://www.dovecds.com/shop/inch/069-jachim-jordan-a-providential-view-of-the-battle-of-yorktown-funshop/. While I gave the lecture, I do not make any money off its sale.
(1) Number of Cornwallis' troops taken from pg. 37 and pg. 76 of Yorktown 1781 by Brendan Morrissey (Oxford: Osprey, 1997). It should be noted here that Cornwallis only had about 4,500 of these troops at the battle of Green Spring; the rest garrisoned points in Virginia.
(2) Lafayette's numbers are taken from pg. 34 and pg. 37 of Yorktown 1781 by Brendan Morrissey (Oxford: Osprey, 1997). Previously, Lafayette's forces had been much smaller; he entered Virginia in the spring of 1781 with about 1,200 Continentals.These appeals and format-conviction challenges took time; the time to exoneration took an indirect of 15 years. We like to work we know them when we see them.
Cozy, which executed people during the study warning