I am trying to define a parent-child relationship in my SSAS project. The dimension is “employee” with a parent being “supervisor”. The source of my data was automatically imported …
Tag: sql
Postgresql select max query takes long time
I have the following structure in a table in my database. Below I list a part of the existing data. https://drive.google.com/file/d/1DrQd6kb523wUZDaqhvkx6WBQxJ3wNT3n/view?usp=sharing My data in text …
Full Join using a fuzzy join but with distinct matching
We have a table of expected payments and a table of payments made. We need to be able to match payments with a singular expected payment but we allow a +-3 day window for it to be made. On top of that, it should be a one-to-one match. So imagine I have a table of expected payments and payments The
Is there an SQL statement that can return maximum values of a column from a table for each of the groups resulting from groupby another column?
I would like to know if we can generate a single SQL statement that; Groups rows in a relational table to n groups based on a given column col_1 Reports the maximum value for each of the groups based on another column col_2. e.g. A dataset has many makes of cars and their respective costs and so we need to
How can I change the layout/structure of my table?
I currently have a table with 3 columns in it. The columns are best described as group_id, task and task_count. There are up to 15 possible tasks and over 500,000 group_ids. The task_count is the number of events that took place in a group_id for that task. Currently, the table looks like this: So in group 55…
Is there a way to group rankings in SQL Teradata?
I am trying to get the ranking or grouping to count like in the custom_ranking column: I want it to count the rank like in the row custom_ranking, but everything I keep trying is counting it in the current_ranking row. I am currently using this: Answer Based on your sample data, this would be:
Oracle : Not a valid function or procedure name
I have to create a procedure that inserts a person to table: When I call the function: I get the error: Answer You can use: Which, if you have the table: Then you can do: And the table contains: ID_OSOBY | IMIE | NAZWISKO | WIEK | STAN_CYWILNY | TELEFON | PESEL | ID_ADRESU ——-: | :— | :̵…
Oracle calculate YTD ,PYTD, QTD , PQTD , MTD, PMTD
My query is Im new to oracle and in my query i have hard coded the values of year ,month and quarter. But i want my query to work without giving any value so that it automatically picks value let me know how can it be done. Answer You can use: (Although I’m not convinced you want the initial ENTRIES,
How to get a first and last value of one column based on another column values
I have a data looks like below. I want to extract the value of the first and last “TS” column based on each “Col” column values (A, B, and C) when it changes. The expected output should be as follows Thanks for your help in advance! Answer This is a type of gaps-and-islands problem. Th…
Names of nodes at depth d for every descendant leaf
I have a category hierarchy that products are attached to. That category hierarchy is saved as an adjacency list. Products can be attached to any category nodes at any level. The category hierarchy is a tree. I would like to… get the name of every level 3 category… per product… where that pr…