My current query is as such: SELECT CAST(COUNT(`MID`) AS UNSIGNED) AS Y, CONCAT( LEFT(MONTHNAME(`date`), 3), ‘ ‘, YEAR(`date`) ) AS …
SQL Count all null values as distinct [closed]
I need to write a query that tells me how many(COUNT) unique customers made a purchase of over $200. My table has a customer_id, purchase_id, and total. purchase_id is unique for every row. …
Sql between query trying to get DATETIME column and not the condition
I’m trying to filter between two DateTimes allowing null values too I’m using OdbcDataAdapter objCon = new OdbcConnection(connStr05); objDA = new OdbcDataAdapter(query, objCon); The connection is …
Selecting distinct values from a join of two large tables
I have an animals table with about 3 million records. The table has, among a few other columns, an id, name, and owner_id column. I have an animal_breeds table with about 2.5 million records. The …
SQL query to display column values as column name in table
I have a field name ‘Title’ from table ‘Greeting’. Title field in UI might come as FirstName or LastName or combination of both. Greeting table looks like: &…
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 …
Cumulative calculation using SQL
I have a supply and a demand table as shown below, Supply Center1 1-Sep 500 Center1 1-Dec 1000 Demand Center1 Req-1 1-Aug 300 Center1 Req-2 15-Aug 250 Center1 Req-3 1-Sep 1100 write …
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 …