Skip to content

Instantly share code, notes, and snippets.

View haydarai's full-sized avatar

Haydar Ali Ismail haydarai

View GitHub Profile
@haydarai
haydarai / catalog_sales.sql
Created December 8, 2018 17:20
Catalog sales
select dd1.d_year, dd2.d_quarter_name, item.i_item_id, catalog_page.cp_start_date_sk, promotion.p_promo_sk, sum(cs_quantity) as quantity
from catalog_sales, date_dim as dd1, date_dim as dd2, item, catalog_page, promotion
where catalog_sales.cs_sold_date_sk = dd1.d_date_sk
and catalog_sales.cs_item_sk = item.i_item_sk
and catalog_sales.cs_catalog_page_sk = catalog_page.cp_catalog_page_sk
and catalog_sales.cs_promo_sk = promotion.p_promo_sk
and catalog_page.cp_start_date_sk = dd2.d_date_sk
group by cube(dd1.d_year, dd2.d_quarter_name, cs_item_sk, catalog_page.cp_start_date_sk, promotion.p_promo_sk)
order by dd1.d_year, dd2.d_quarter_name, cs_item_sk, p_promo_sk
@haydarai
haydarai / store_sales.sql
Created December 8, 2018 15:47
Store Sales
select date_dim.d_year, store.s_store_name, promotion.p_promo_sk, item.i_item_id, sum(ss_quantity) as quantity
from store_sales, date_dim, item, store, promotion
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
and store_sales.ss_item_sk = item.i_item_sk
and store_sales.ss_store_sk = store.s_store_sk
and store_sales.ss_promo_sk = promotion.p_promo_sk
group by cube(date_dim.d_year, ss_item_sk, ss_store_sk, ss_promo_sk)
order by date_dim.d_year, s_store_name, promotion.p_promo_id
@haydarai
haydarai / web_sales.sql
Last active December 8, 2018 15:18
Web Sales
select date_dim.d_year, web_site.web_name, item.i_item_id, promotion.p_promo_id, sum(ws_quantity) as quantity
from web_sales, date_dim, item, web_site, promotion
where web_sales.ws_sold_date_sk = date_dim.d_date_sk
and web_sales.ws_item_sk = item.i_item_sk
and web_sales.ws_web_site_sk = web_site.web_site_sk
and web_sales.ws_promo_sk = promotion.p_promo_sk
group by cube(date_dim.d_year, ws_item_sk, ws_web_site_sk, ws_promo_sk)
order by date_dim.d_year, web_site.web_name, promotion.p_promo_id
df['year']=df['Date'].apply(get_year)
years=df['year'].unique().tolist()
for year in years:
df_current_year=df[df['year'] == year]
year_statistic=df_current_year['LSOA_of_Accident_Location'].value_counts()
# TODO: plot each year statistic
print(year_statistic)
private class SomeModel {
public float y { get; set; }
public float m { get; set; }
public float x { get; set; }
public float b { get; set; }
... // constructor, methods, or anything else
}
private SomeModel(Variable variable) {
private Dictionary<string, float>(Variable variable) {
... // do computation depends on what the method is all about
/**
* Creating dictionary and assign it
**/
Dictionary<string, float> dictionary = new Dictionary<string, float>();
dictionary.add("y", y);
dictionary.add("m", m);
dictionary.add("x", x);
int y;
int m;
int x;
int b;
private void someMethod(Variable variable) {
... // do computation depends on what the method is all about
/**
* Assigning those global variables
if (dictionary.ContainsKey("banana")
{
int banana = dictionary["banana"];
}
Dictionary<string, int> dictionary = new Dictionary<string, int>();
dictionary.Add("banana", 1);
dictionary.Add("watermelon", 3);
dictionary.Add("grape", 2);
dictionary.Add("apple", 10);
List<Post> posts = ...; // Fill the list with data
List<Post> filteredPost = Stream.of(posts) // Convert the list into a Stream object
.filter(post -> post.getAuthor().equals("Haydar") // This is the condition which the Stream will filter
.collect(Collectors.toList())); // Return the new filtered list