I have some update statements like this: UPDATE tmp SET MyVarCharColumn1 = ISNULL(SomeOtherVarCharColumn,0) FROM #myTempTable tmp; Note that MyVarCharColumn1 is of type VarChar() but in real …
Merge update records in a final table
I have a user table in Hive of the form: User: Id String, Name String, Col1 String, UpdateTimestamp Timestamp I’m inserting data in this table from a file which has the following format: I/U,…
STRING_SPLIT in TSQL on MS Server creates list with repeating values. WHY?
I am using 2017 MS SQL Express. The following code creates this erroneous result. Any clues why? SELECT BNAME, LIC_STRING INTO dbo.SEPARATE2 FROM dbo.together CROSS APPLY STRING_SPLIT(LIC_STRING, ‘,’)…
How to pulls related values in PostgreSQL?
Here is my problem. I have two tables like user and customer. Users can be related to some customer(s). For example, I have a user who relates to two customers, and the other user relates to three …
Postgres database migrations with vault
I am currently using vault to generate database credentials. The service itself handles migrations against the database. I end up with tables owned by the generated vault role. the database …
Max date over each item
I have a table that simplified looks like this: WITH TBL (ITEM, COST, DAY) AS ( SELECT ‘A’, 6, TO_DATE(‘2019-08-13’, ‘YYYY-MM-DD’) FROM DUAL UNION ALL SELECT ‘B’, 4, TO_DATE(‘2019-08-21’, ‘YYYY-…
Sqlite SUM Entity value depending on LEFT JOIN value
I’m using Room on Android to query a POJO. My POJO (Transaction) contains a value and an account_id. It further contains an account (instance of Account), which is fetched by a @Relation. The …
How to remove Repeated field in BigQuery schema?
I have a schema that has a repeated field nested into another repeated field like so: person.children.toys. I want to make this inner field not repeated (so child can have only single nullable toy). I …
Count rows that don’t match between two tables within a group
I have two tables, each with a user_id, and group_name columns. E.g. table1: | user_id | group_name1| ———————— | 1 | ‘groupA’ | | 1 | ‘groupB’ | | 2 | ‘…
How to calculate the percentage of salary paid by each account for each employee?
I need to find the percentage of an employee’s salary that is paid by each account. For example.. I need to find a way to sum the amounts of each employee and then divide each amount by that total. …