Is it possible to get a the sum of value from the calendar_table to the main_table without joining like below? I am trying to avoid a join like this because main_table is a very large table with rows that have very large start and end dates, and it is absolutely killing my performance. And I’ve already …
Tag: sql
ORA-06502: PL/SQL: numeric or value error when concatenating
I am getting error as numeric or value error Answer The problem is with operator precedence: Oracle evaluates operators with equal precedence from left to right within an expression. … and as the table shows + and || have equal precedence. So in this statement: this is interpreted as ‘sum = ‘…
Sql query with max value in where condition
I have a query which should return one row if the conditions are met. This query compares columns from 3 tables and should use the max value of DEGREE_HIERARCHY since there can be more than one value. …
Insert rows into same table using data from different rows based on data from another table
I’ve got 2 tables: TimecardSetDetails, TimecardDetails TimecardSetDetails +————–+————-+————–+ | SetDetailsID | EmployeeKey | SetHistoryID | +————–+————-+—–…
COUNT Multiple Columns using GROUP BY – SQL
I am trying to create a GROUP BY COUNT of ~30 columns in my database. The database is basically a shiftplan, where on each column a row can be assigned different shift types (denoted as a D, N, A, X, F, C, etc..). I can use the following query to get a count of each shift type, am struggling to
SQL Join – Limit to base table
I have 4 tables that I want to link together based on the information in the sales_details table which will serve as the base table (limiting results based on the sales_details table) 1)I want to pull all columns from the sales_detail table that are mastercard orders but since the sales_detail table doesnR…
SQL – Find most recent value from other fields (per user, between occurrences)
I have actions and results mixed together in an “event” field. But each of these actions essentially “causes” the result (and the subsequent outcome) (let’s assume). I want to tie each future outcome back to the actions that caused it, for each user. I want the value from the …
‘cannot extract element from a scalar’ when order by id is DESC
I have a PostgreSQL 9.3.10 database, a table with 15842 records and use Intellij for making queries. I want to query some recent data from JSON column (named ‘data’). My query is that simple: The problem is that I get: [22023] ERROR: cannot extract element from a scalar when I use desc order. When…
How to filter within a Window Function PostgreSQL
I only want to filter in Window function to keep the created_at is null so I don’t use WHERE clause previously. Because when I order by created_at desc it will show the null value first. How to add a …
sequelize updating multiple rows
Update multiple rows , is using a bulk update a good solution or something like the code below works ? . I supposed wanted to update all the records with the id and filename. I did try to update …