I would like to fetch the sum of field TOTAL for active users and sum of field TOTAL for inactive users. Expecting is the query that results activeTotal = 15 and InactiveTotal = 50 SELECT SUM(actUser.total) as activeTotal, SUM(inActUser.total) as inactiveTotal FROM user actUser JOIN user inActUser ON inActUser.id = inActUser.id WHERE (actUser.active = 1 AND actUser.userId = 1) OR
Tag: sql
How to change max_connections_per_hour in XAMPP?
In my production environment I’m getting this error: I don’t have this problem in my development environment so I need to set the max_connections_per_hour to 500 in order to replicate it. How do I do this? My database is run from the XAMPP control panel. I don’t see this variable name in my.config, which is also accessed from the XAMPP
Get users attendance entry and exit in one row SQL Server
I have a table with all entries for employees. I need to get all the working hours and the entry and exit time of the user in one record. The table is like this: How can I do that and also in case there is some missing entries or exit. Like one employee will have entry with no exit in
PostgreSQL cyclic foreign keys to multiple tables
I have 3 tables. chat_room group_chat_room private_chat_room As you can see chat_room has foreign key constraints that refer to group_chat_room and private_chat_room. Also both group_chat_room and private_chat_room have FK constraints that refer to chat_room. When I want to INSERT a row into group_chat_room I would use this However because of those constraints this would produce an error [23503] ERROR: insert
convert access group by query to sql server query
I’m unable to convert MS Access query to SQL SERVER Query, with changing the group by columns because it will effect in the final result. The purpose of this query is to calculate the Creditor and …
Postgres, how to limit number of rows returned from joined tables
I have the following query that return the data I want, however for the joined tables, I want to limit the number of rows returned and preferrably be able to specify for each joined table. I tried …
Is there a way to use MySQL fulltext to search related tables?
I have a table called persons which contains data about, well, people. It also contains foreign keys to another table. I’d like to make a fulltext index that is able to search the related tables for …
SQL Query – How to apply different conditions (Where clause?) to specific aggregated columns
I have a table (simplified example below) consisting of TEST(s), TESTPRICE per test and TESTSTATUS. I would like to be able to run a query that will result in two aggregated columns, one for pending …
How to calculate weekly and monthly appearances of distinct string values in SQL Google Big Query?
I am new to SQL, and I have a dataset with date values and domain column. Domain column only contains values ‘personal’ and ‘business’. What I am trying to accomplish is to calculate weekly and …
SQLite Delete row from Table A when columns are referenced as FOREIGN KEYS in other Tables B, C, etc
So I have several tables, but will show only 2 as an example: Table G gNo | gName | gAddress G1 | Jean | Bonalbo G2 | Oscar | Berlin G3 | Edd | Brisbane G4 | Bob | California Table B gNo | …