I’m new to Loopback 4 and I’ve been trying to execute a native SQL query. I found how to do it, the thing is that don’t have any clue of WHERE to put it in my code in order for it to work… here’s the documentation I found. I need to know where should I put this: in my Loopback
Tag: sql
Statistical functions on columns of arrays in BigQuery
If I have data that looks like the follows: +——+————+——-+ | a | val | val2 | +——+————+——-+ | 3.14 | [1, 2, 3] | [2, 3]| | 1.59 | [7, 8, 9] | … | | -1 …
Calculate Time Between Logins by User in Bigquery
I am trying to calculate the time difference between 2 login events in BigQuery, by user. I want to understand how long it takes between logins for each user. I’ve tried with the following query: Sample Data user_id event timestamp aaa Login 2021-02-20 00:00:00 UTC bbb Login 2021-02-20 00:02:00 UTC aaa …
Multiple Loop with a SQL Query Function – 2 Minute Interval between Queries
Need to loop twice through the query function below loading the results into two seperate variables. The query function works as expected, but need to have two unique queries stored in the two temp tables. How should I create these temporary tables that allow me to reference them as $1_resultsDataTable and $2…
Create Athena table using JOOQ java
How can I create a Athena table using jooq library in java. Since Athena table uses syntax like create external table and we need to specifiy s3 bucket path also. I have a list of string from which i want to create the athena table. Can somebody suggest a way how i can do it with jooq library. Answer Amazon
How create Postgres database using SQLAlchemy
I want write project using database library (SQLAlchemy). When I use SQLite, all works good, but when I deploy project on server (Heroku with Postgres plugin), It doesn’t work. This is code for my database: I have engine & Base variable: In DATABASE_URL link to base on Heroku(Postgres). For create d…
SQL – Selecting rows based on date difference
Suppose we have below table: Code Dt c1 2020-10-01 c1 2020-10-05 c1 2020-10-09 c1 2020-10-10 c1 2020-10-20 c2 2020-10-07 c2 2020-10-09 c2 2020-10-15 c2 2020-10-16 c2 2020-10-20 c2 2020-10-24 Combination of Code and Dt is unique. Rows are sorted based on Code and Dt. Database is Oracle 12. For every code, I wa…
Logs of executed Query in SQL Server
Database having 5 users All users are running queries on database we need to find what are the things all users doing like (Query , session_id,starttime , endtime,Database name,username , hostname ) we need to insert all the data into one table. Answer
Finding the difference between two rows in SQL and assigning a numerical value to it (SQLite)
I have a table name login_time John 2021-01-02 08:10:52 John 2021-01-02 11:55:01 John 2021-01-04 17:36:22 Amy 2021-01-02 10:12:48 Amy 2021-01-06 11:22:41 Amy 2021-01-06 19:05:07 I want to add a usage_days column. If the same user login within the same day of his last login time, it is considered as the same d…
Trigger to update a table whenever there is an insert
I am trying to use a trigger (in SQL Server) to update a table whenever there is an insert on the table but I get an error: Conversion failed when converting date and/or time from character string. Trigger used: The table table_scan is to be updated when there is NULL in start_date after an insert happens. An…