+------------+-----------------+---------------------------+ | Category | Product Name | Product Description | +------------+-----------------+---------------------------+ | Casual | Black Shoe | This is a shoe | | Electronic | Washing Machine | This is a washing machine | | Electronic | TV | This is a tv | | Casual | Blue Trousers | This is trousers | | Casual | White Shoe | This is a shoe | | Casual | Blue Shoe | This is a shoe | +------------+-----------------+---------------------------+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class MyTest { | |
private static int shortestPath(int[] from, int[] to, int source, int destination) { | |
Map<Integer, Set<Integer>> graph = getGraph(from, to); | |
return iterate(graph, new HashSet<>(), source, destination); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
user_id, | |
LAST_VALUE(location)over w, | |
event_time | |
from my_users | |
window as (user_id by category order by event_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
user_id, | |
LAST_VALUE(location)over w, | |
event_time | |
from my_users | |
window as ( | |
user_id by category | |
order by event_time | |
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
user_id, | |
LAST_VALUE(location)over w, | |
event_time | |
from my_users | |
window as ( | |
user_id by category | |
order by event_time | |
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | |
) |
Category | Product Name | Product Description |
---|---|---|
Casual | Black Shoe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
p.category, | |
p.product_name, | |
p.product_description | |
FROM ( | |
SELECT | |
p.category, | |
p.product_name, | |
p.product_description, | |
rank() over w1 rnk |
Category | Product Name | Product Description |
---|---|---|
Casual | Black Shoe | This is a shoe |
Electronic | Washing Machine | This is a washing machine |
Electronic | TV | This is a tv |
Casual | Blue Trousers | This is trousers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
p.category, | |
p.product_name, | |
p.product_description | |
FROM ( | |
SELECT | |
p.category, | |
p.product_name, | |
p.product_description, | |
(percent_rank() OVER w1) * 100 AS percent_rnk |
Category | Product Name | Product Description |
---|---|---|
Casual | Black Shoe | This is a shoe |
Electronic | Washing Machine | This is a washing machine |
Casual | Blue Trousers | This is trousers |