I am working with a data set of clients and their date records. I am trying to apply a gaps and island problem only using MONTHS,( currently var char ‘YYYYMM’). I need to take individual records and …
Tag: sql
SQL query to get child count and sum it
My table is kind of like : ID CODE SUB_CODE —— —— ———— | 1 | A | A1 | ————————– | 2 | A | A1 | ————————– …
Is it possible to create a table with a hh:mm time column?
I want to create a table column that has a hh:mm format. How do I do that? I’ve tried it with time(0) but that also gives me the seconds. CREATE TABLE courseTimes ( startingTime time(0), …
Is there a difference between Oracle SQL ‘KEEP’ for multiple columns and ‘KEEP’ for one and GROUP BY for the rest?
I’m just now learning about KEEP in Oracle SQL, but I cannot seem to find documentation that explains why their examples use KEEP in all columns that are not indexed. I have a table with 5 columns …
SQL Query with date range Male Female
I have a query that works but I need to incorporate in that query the following: For male date is older or equals 3 months; For female date is older or equals 4 months; SELECT * FROM Davaoci WHERE …
In MariaDB/MySQL, how do I retrieve the same column from different records returned in a single row?
I would like to retrieve a single row that shows the top three colors of products belonging to a specific set. The order is predefined and for some context, the way I would retrieve the top color is …
How to select data that doesn’t exist in other query
I’m trying to select from table data but i want the result not exist in this select. (SELECT * FROM data WHERE category = ‘A’ ORDER BY RAND() LIMIT 4) UNION ALL (SELECT * FROM data WHERE category = ‘…
How to add parameters in a SQL select query?
How to add parameters in a SQL select query? string time = 2013-09-25 00:00:00; I wish to use the time variable in the below mentioned SQL query Select LastUpdated from Employee where LastUpdated &…
PostgreSQL string_agg, default value when no value found
I have a table like this: date number system_id 1 33.1 1 2 24.2 1 3 14.1 1 4 15.5 1 5 1113 1 1 4513 2 2 53….
Selecting and ordering by the top from each country
I am scoring events where there are 2 individuals from each country in an event, BUT only the top finisher from a country receives points. If a country finishes 1st and 2nd, the 2nd place is dropped …