my_table shows the account balance of each person’s credits N months ago. From this table, I want to get the monthly sum of each person’s balances for the past 2 and 3 months and divide each sum by 2 …
Tag: conditional-statements
Selecting default row if no rows return with join condition values from other tables
I have two tables ORDERS and RATE: and I would like to get the costs of all the orders in table ORDERS, given that a default rate of 10 is used for those orders which do not have rates in the RATE table for the corresponding ids, and if an id is available in the RATE table, but no rate
Is there an SQL function that let us put condition above WHERE clause?
I have some query with several WHERE clauses. Based on an external variable :flag, I would like to set a condition when I can use a WHERE clause. Below is a presentation of what I mean. There is a …
How to select a record if it is equal to any record of a column from a different table?
I have a table with adresses, which were separated by spaces into different columns. Since the name of the streets can be made up from 1-2-3 etc. parts, the street suffices are placed in different …
SQL – Calculating third column from previous two
I have just started SQL and have some difficulties in terms of thinking in this language. I have now a task where I need to create a new column in a table with values from previous columns. This …
Replace Database field based on 2 different Table Conditions
I need to update the table based on email matching condition and need to know SQL query that can solve this problem. I have 2 tables “old_data” and “new_data” Old_data contains around 60,000 records …