I have 2 tables, Assets and Main. I want to create a query that will total the transactions in Main, grouped by each account in Assets. But there’s a catch: sometimes the amt needs to be summed as a …
SQL subquery with latest record
I’ve read just about every question on here that I can find that is referencing getting the latest record from a subquery, but I just can’t work out how to make it work in my situation. I’m creating …
MySQL: select row only where closest to date has column value
I want to return all rows that were public in May (2019-05), so if a row was turned to draft (and not back to public) at any point before the end of May, I don’t want it. For example: id | post_id | …
How to use BETWEEN condition for array column in Postgres?
I have a multiple_dates column in a Postgres DB. To find by a specific date I’m writing like this: SELECT * FROM companies WHERE ‘2019-06-30’ = ANY (multiple_dates) But I want to search by a …
MySQL how to check if value starts with letter and ends with a number?
I want to show specific data where all the values start with a letter and ends with a number in the city of cansas only. What my table looks like: hotelroom pID |name | city | key —–…
How to block table in booking?
How to block table to booking? My booking table has from_datetime and to_datetime fields. I would like to avoid situation, when two users book something in the same time. My attempts: TERMINAL 1: – …
Get nth result in Partition if n-1, n-2.. results are within 30 days of n
+———-+———–+———–+———–+———-+ | ClientID | EpisodeID | StartDT | EndDT | Location | +———-+———–+———–+———–+—…
How to get the Exact Batch ID from stock table on the basis of Expiry Date?
I want to get the batch id from stock table on the basic of fifo expiry date. How to get it. I write a query it give the exact batch but batch id not accurate. Basically I want to Fetch the batch is …
Is it possible to look at two consecutive rows and determine the difference in time between the two using SQL?
I am relatively new to SQL, so please bear with me! I am trying to see how many customers make a purchase after being dormant for two years. Relevant fields include cust_id and purchase_date (there …
Access – Multiple Criteria On Multiple Fields – Only Exclude Specific Match
Example Sku Qty Apple 1 Orange 1 Apple 3 Orange 4 I want to exclude anything that is Exactly Orange* with a qty of 1. If I do WHERE ((QTY)>1) AND ((SKU) NOT “Orange”) the result …