I am trying to get all rows where the states are greater than 1. My table: user_id|state ————– 1000000|Active 1000000|Created 1000001|Active 1000000|Deleted 1000002|Active 1000001|Created …
Tag: sql
Accounting Data Warehouse Design Question
The finance module in our ERP has a general ledger and sub-ledgers (accounts receivable, accounts payable etc.). All the sub-ledgers are rolled up into the GL. Standard accounting schema I believe I …
How to join two tables in one view?
I am trying to create a view where I can see the items that have been planned to be shipped and have not been shipped, and the items have have been shipped but were not planned to. In order to do …
Sequelize Include with Where Condition
I’m having a problem with how to query multiple include with where condition. Tried it using direct query to sql and it works fine. I made a sample using sql and having a problem converting it to …
Recursive Iterator for a single table
I have a table in which the foreign key refers to the id of the same table. I need to find the children of the first element that pass me as a parameter, until I reach a certain level. I need to find …
Find the top of the Hierarchy
I have the following table: employees employee emp_id manager manager_id a 1 x 1 b 2 a 1 c 3 b 2 I am trying to show x 1 is the top …
What does the two dot before a table name mean
I’ve seen a query that looks like this: Select Id from ..TableName where [Name] = @MyName I can’t seem to find when, or why this would be used. The query session is run against a database (So there …
How to calculate hours that a clinic is open taking into account break times
I am using MariaDB 10.3. I am attempting to derive how many hours a clinic is actually open for a given weekday from an provider schedule table. The clinic is considered “closed” if (1) all …
Dynamically Updating Columns with new Data
I am handling an SQL table with over 10K+ Values, essentially it controls updating the status of a production station over the day. Currently the SQL server will report a new message at the current …
How can I safely create a query that will list column names given a table name, and a connection string which may point to SQL Server or MySQL?
I have the following method at the moment which works for my particular two databases, but I’m not sure if it’s the correct way to achieve my goal of listing column names, or is a bit hacky. One part …