I know the syntax of the IIf function in SQL is IIf(Boolean_Expression, True_Value, False_Value) But I just found a SQL Code where is written IIf([DATE_USER_TO_SPECIALIST] Is Not Null, Year([…
Tag: database
Differences between OLAP and OLTP databases
What are the key differences between OLAP and OLTP databases. Specifically in terms of implementation (rather than use cases). OLAP is of course primarily used for reporting while OLTP is used for …
How can i get a count(*) of all the columns in a table? Using PostgreSql
I have bunch of tables where several of them have hundreds of columns. I need to get a count of non-null values for each column and I’ve been doing it manually. I would like to figure out a way to get …
Why is MySQL SUM query only returning one row?
I am trying to create a MySQL query to return the sum of all statement balances for each account in my DB. The query looks like this: SELECT SUM(balance), handle FROM statement_versions INNER JOIN …
Aggregations in SQLite
I am looking to construct a SQL query which is able to sum up installment values by month. Ordinarily this wouldn’t be too hard as you would simply sum the installment values and group by month. …
SQL: Give the names of employees who earn more than their manager
Hi guys, I have this type of table, and I need to show the employees who earn more than there managers? It would be easier if we had 2 tables, but I cannot imagine a code within one table. Any ideas? Answer You can do “self-join” between the two tables. In the second table, EMPNO will be equal to the
Hive Case Resulting Duplicate Row
I have a table containing contact numbers and another reference table containing a “length” variable and a number column. What I need is to find the prefix name where the prefix of the number matches …
PHP Database Query foreign key data from database
I try to build a simple blog system. database table like below. Posts +—-+———-+————-+ |id | title | content | +—-+———-+————-+ |1 | Tile | Content | +…
SQL – min(date) with conditionals
We ran a promotion where users can receive their first subscription order free. Price = $0.00 when a user uses the promo. I am interested in the data from Example A. Example A – User 50 started with …
How to export Excel data from different sheets to SQL-SERVER Database?
I am new in Excel VBA and SQL. I have managed to create a macro button and push Excel cell data to SQL server tables. However, I am a bit puzzled: How can I take Excel cell data from different sheets and then push them to different tables in SQL Server database? (Currently, I have 3 sheets – Customers, Test,