I am trying to take a table and in Microsoft 2016 Access and use SQL to unnest a single column into multiple rows instead. It is comma separated. I tried adding Unnest and keep getting errors, maybe I am missing something. This BOGO_Sale.promo_parent_skus is the only column I am trying to unnest into rows. An…
Tag: sql
Calculate TimeDiff in Pandas based on a column values
Having a dataframe like that: Desirable result is to get aggregated IDs with time diffs between Start and End looking like that: Tried simple groupings and diffs but it does not work: How this task can be done in pandas? Thanks! Answer A possible solution is to join the table on itself like this: Output:
How to divide with each other the two queries with different conditions?
There is a table in which the managers column and the status column. How to calculate the total status of Fully, the divided total of records with all statuses except N / A for each manager? I tried to portray in this way, but nothing came of it First Query Second Query Need to recieve two columns with name a…
how to use GROUP BY based on 2 specific columns
I have a table in SQL Server which looks like this : each ticket id can have multiple order issue. On each row I need to calculate ticket full revenue as below : SUM(revenue) of all items within the same ticket id So in my case, ticket id has 3 items (10,20,30) so the ticket full revenue = 30+5+15 =
mysql Cumulative sum for each unique ID in each sale:
I have trouble adding and accumulating my amounts per id, I use this solution but it doesn’t work and it adds up all the ids, I use this: any solution? ineed this For version 5.7 ? Answer You can use a SELECT statement containing window analytic function instead of an UPDATE statement : acumulado column…
SQL order with equal group size
I have a table with columns month, name and transaction_id. I would like to count the number of transactions per month and name. However, for each month I want to have the top N names with the highest …
What is the correct syntax?
I wrote a sql query to update data of ‘tbl_products’. Here is the query update tbl_products set product_count = (product_count – tbl_order_details.product_sales_quantity) from tbl_products join …
Store procedures for delete a repeat records
Hello i have a table in MySQL: “contracts” where i create a 3 record’s for each client_id, but one bug in the backend create more records on some client_id i try create a store procedure to …
calculate the percentage with sql and DOMO
I have a table where I want to calculate the percentage of revenue using the following formula: (Advertiser Revenue / Total Revenue) * 100. Data => Here is my code and what I have tried: Error: syntax error: execute command denied to user Answer In Domo, this calculation would best be done at the visualiza…
Return multiple values in varchar2
I want to return the values of several columns (With a function) in a varchar2 but I get an error when I choose several columns in select. FUNCTION FU_PRUEBAS (P_IDNUM MAC.IDNUM%TYPE) RETURN VARCHAR2 …