Skip to content

Can I use Window (Analytic) function? #58

Answered by EvgSkv
koji-m asked this question in Q&A
Discussion options

You must be logged in to vote

Hello.
Yes, you can!
Since we are still not sure what's the best syntax for those in Logica for now this part needs to be written in SQL with SqlExpr.
Here is how your query can be written:

Summary(id:, amount:, ranking:) :-
  my_dataset.pos_data(id:, amount:),
  ranking == SqlExpr("RANK() OVER (ORDER BY amount DESC)", {});

which compiles to

SELECT
  my_dataset_pos_data.id AS id,
  my_dataset_pos_data.amount AS amount,
  RANK() OVER (ORDER BY amount DESC) AS ranking
FROM
  my_dataset.pos_data AS my_dataset_pos_data;

Please let me know if you have further questions.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@koji-m
Comment options

@EvgSkv
Comment options

@koji-m
Comment options

@EvgSkv
Comment options

@scottedwards2000
Comment options

Answer selected by koji-m
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants