Skip to content

Instantly share code, notes, and snippets.

View avisheknagi's full-sized avatar

Avishek Nagi avisheknagi

View GitHub Profile
@avisheknagi
avisheknagi / pip_install.sh
Last active November 3, 2017 22:52
pip_install
py -m pip install <package name>
py -m pip uninstall <package name>
##Note: replace <package name> desired package (e.g., nltk, pyautogui, pandas etc...)
@avisheknagi
avisheknagi / stats_equations.Rmd
Created November 1, 2017 05:12 — forked from derekmcloughlin/stats_equations.Rmd
Useful Latex Equations used in R Markdown for Statistics
---
title: "Sample Equations used in Statistics"
output: html_document
---
### Summations
### Without Indices
$\sum x_{i}$
@avisheknagi
avisheknagi / final2.sql
Created October 28, 2017 03:27
T-sql Final2
--1. Get the order ID and unit price for each order by joining the Orders table and the Order Details table.
SELECT o.OrderID, od.UnitPrice
FROM dbo.Orders AS o
JOIN dbo.[Order Details] AS od
ON o.OrderID = od.OrderID;
--2. Get the order ID and first name of the associated employee by joining the Orders and Employees tables.
SELECT o.OrderID, e.FirstName
@avisheknagi
avisheknagi / WeatherOStation3.sql
Created October 17, 2017 15:41
Weather Observation Station 3
--The SQL DISTINCT command along with the SQL MOD() function is used to retrieve only unique records depending on the specified column or expression.
SELECT DISTINCT City FROM Station WHERE MOD(ID,2)=0
@avisheknagi
avisheknagi / final1.sql
Created October 15, 2017 20:00
Querying with Transact-SQL_F1
--Q1. Select the quantity per unit for all products in the Products table.
SELECT QuantityPerUnit FROM Products
--Q2.Select the unique category IDs from the Products table.
SELECT Distinct CategoryID FROM Products
--Q3. Select the names of products from the Products table which have more than 20 units left in stock.
SELECT ProductName FROM Products
WHERE UnitsInStock >20
@avisheknagi
avisheknagi / RetrievingSStatus
Created October 5, 2017 02:34
Retrieving Shipping Status
SELECT SalesOrderID, OrderDate,
CASE
WHEN ShipDate IS NULL THEN 'Awaiting Shipment'
ELSE 'Shipped'
END AS ShippingStatus
FROM SalesLT.SalesOrderHeader;
@avisheknagi
avisheknagi / RetrievingPrimaryContact
Created October 5, 2017 02:28
Retrieving Primary Contact Details
-- select the CustomerID, and use COALESCE with EmailAddress and Phone columns
SELECT CustomerID, COALESCE(EmailAddress, Phone) AS PrimaryContact
FROM SalesLT.Customer;
@avisheknagi
avisheknagi / RetrievingCName.sql
Last active October 17, 2017 02:45
Retrieving Customer Contact Names
-- use ISNULL to check for middle names and concatenate with FirstName and LastName
SELECT FirstName + ' ' + ISNULL(MiddleName + ' ', '') + LastName
AS CustomerName
FROM SalesLT.Customer;
@avisheknagi
avisheknagi / RetrievingCSdata2.sql
Last active October 17, 2017 02:44
Retrieving Customer and Sales Data (2)
-- finish the query
SELECT SalesOrderNumber + ' (' + STR(RevisionNumber, 1) + ')' AS OrderRevision,
CONVERT(nvarchar(30), OrderDate, 102) AS OrderDate
FROM SalesLT.SalesOrderHeader;
@avisheknagi
avisheknagi / RetrievingCSdata.sql
Last active October 17, 2017 02:43
Retrieving Customer and Sales Data
-- cast the CustomerID column to a VARCHAR and concatenate with the CompanyName column
SELECT CAST(CustomerID AS varchar) + ': ' + CompanyName AS CustomerCompany
FROM SalesLT.Customer;