N

@naren

Dividends

MySQL
2 years ago
-- What is the JPMorgan Chase & Co. (JPM) continuous dividend paid years, Consecutive Years of dividend Growth? -- Drop table Dividends; -- create a table CREATE TABLE Dividends ( stock VARCHAR(255), sector VARCHAR(255), tier VARCHAR(25

First of each Group

MySQL
2 years ago
# The blog post link: https://dataisadope.com/blog/sql-blunders/ -- create a table CREATE TABLE cats ( name VARCHAR(255), breed VARCHAR(255), weight FLOAT, color VARCHAR(255), age INT );

Examining nearby rows

MySQL
2 years ago
-- Create the cats table CREATE TABLE cats ( name VARCHAR(50), breed VARCHAR(50), weight FLOAT, color VARCHAR(50), age INT ); -- Insert data into the cats table

Active users - Gaps and Islands in SQL

MySQL
2 years ago
CREATE TABLE Accounts ( id INT PRIMARY KEY, name VARCHAR(255) ); CREATE TABLE Logins ( id INT, login_date DATE, FOREIGN KEY (id) REFERENCES Accounts(id) );

Window Function - Team size

MySQL
2 years ago
-- create a table CREATE TABLE Employee ( employee_id INTEGER PRIMARY KEY, team_id INTEGER NOT NULL ); -- insert some values INSERT INTO Employee VALUES (1, 8); INSERT INTO Employee VALUES (2, 8); INSERT INTO Employee VALUES (3, 8);

Delete duplicate data

MySQL
2 years ago
-- Delete duplicate data create table cars ( model_id int primary key, model_name varchar(100), color varchar(100), brand varchar(100) );

Checking type equality

Python
2 years ago
from collections import namedtuple def checking_type_equality_bad(): Point = namedtuple('Point', ['x', 'y']) p = Point(1, 2) if type(p) == tuple: # Liskov substitution violation print("it's a tuple") else: print("it

Comprehensions

Python
2 years ago
def never_using_comprehensions(): squares = {} for i in range(10): squares[i] = i * i print(squares) def using_comprehensions(): odd_squares = {i: i * i for i in range(10)} print(odd_squares)

Practice python

Python
2 years ago
a=1 def do(x): return(x+a) print(do(1)) class Points(object): def __init__(self,x,y):

fetch the second last record

MySQL
2 years ago
-- Tables Structure: create table employee ( emp_ID int primary key , emp_NAME varchar(50) not null , DEPT_NAME varchar(50) , SALARY int); insert into employee values(101, 'Mohan', 'Admin', 4000); insert into employee values(102, 'Rajkumar', 'HR',

fetch all the duplicates

MySQL
2 years ago
-- Tables Structure: create table users ( user_id int primary key, user_name varchar(30) not null, email varchar(50)); insert into users values (1, 'Sumit', 'sumit@gmail.com'),

JOINS

MySQL
2 years ago
-- create CONTINENTS table CREATE TABLE continents ( continent_code VARCHAR(2) NOT NULL, continent_name VARCHAR(30) NOT NULL, PRIMARY KEY (continent_code) ); -- create COUNTRIES table CREATE TABLE countries ( country_code VARCHAR(2) PRIMARY

ROW_NUMBER-RANK-DENSE_RANK

MySQL
2 years ago
-- create a table CREATE TABLE employee ( first varchar(20), last varchar(20), age int, salary int, location varchar(20) ); insert into employee values('sachin','sharma',28,10000,'Bangalore');

Over(Partition By) Clause

MySQL
2 years ago
-- create a table CREATE TABLE employee ( first varchar(20), last varchar(20), age int, salary int, location varchar(20) ); insert into employee values('sachin','sharma',28,10000,'Bangalore');