I am doing a cohort analysis using the table TRANSACTIONS. Below is the table schema, Below is a quick query to see how USER_ID 12345 (an example) goes through the different cohorts based on the date filter provided, The result for this query with the time frame (two weeks) would be and this USER_ID would be …
Tag: sql
I’m getting the OleDb exception ‘Unspecified error the scale is Invalid’ when trying to use a stored procedure
I made a stored procedure in SQLExpress to insert information in both the Header and Details table. I’ve ran the stored procedure in SQL Server Management Studio to make sure it works fine. But when I try to use the stored procedure using TableAdapters in visual studio it gives me the error: System.Data…
Connect MQTT Message with clienID of Publisher
I want to store MQTT data in an MySQL db and want to store the client id, topic and message content. With some devices, I have no control over the topic or message syntax, so it will not be possible to attach the client id to the message or add the client id in the topic. Is there a possibility
Column is not being grouped exception in Scatterplot
I am trying to create a Scatter chart in OmniSci with a Y-Axis set to the following custom measure: but the chart fails to render and throws the following exception: What would be the best way to “group by” the footage_drilled field so that it complys with the Scatterplot requirements? Answer I be…
how to make cohort analysis in mysql
I have a table called order_star_member: DB Fiddle I want to find users in the month March with transaction >= 700000 and first transaction >= 700000. The user whose transaction is >= 700000 is called star member. My query so far: Explanation: in march 2021, there’s only one ‘star member&…
Count number of weeks, days and months from a certain date in PySpark
So, I have a DataFrame of this type: And I want to create multiple columns containing, for each line, the current day, week, month and year from a certain date(simply a year, like 2020 for 2020-01-01). At first I thought of using something like this line of code unfortunately this wouldn’t work (except …
how to rollback tran when error occur in oracle
i try to solve 2 requests below but i only code for the first one,, can any one help to solve the second one Write SQL statements using cursor to update salary of all employees base on update conditionals Make sure all update records have been updated completely. The database transaction will be rolled back i…
Find students who take most courses SQL
Assume there’s a table students containing student id, semester id and number of courses taken in each semester: How can I find students in each semester who took the largest number of courses? Expected output would be: I thought of using OVER PARTITION BY, but I’m not sure how to use it correctly…
Postgres trigger to update counter in another table not working
There is users table and places table. The users table has column id(primary key), username, place_count. The places table has column id(primary key), name, user_id (user_id foreign key) Each user can post multiple photos and so I want the column”place_count” to keep the count of user-specific pla…
(SQL) Create Table with Distances from Separate Table with XY Coordinates
I am trying to create a table that will have unique distances between slot machines based on the following dataset. I know I first need to calculate my distances and the only way I currently know how would be to use the following code: But this obviously only returns the distance between the first two machine…