I have a scenario: as per my sysdate i need to capture last 12 months dates. Example: I will be getting a parameter which is numeric like : 2,3,4,6 .. If the parameter is 3: then as per sysdate-12 …
Conditionally add a column with a default value to an existing table in SQL Server
I want to add a new column in existing SQL table with default values depending upon some cases/conditions. I want to know if this is possible. If yes how? if not why? Alternative : One option is …
Group rows in Oracle using PARTITION BY
I have below 2 tables which i want to display like shown result Data Table 1 id col1 col2 t1 data1 data2 t2 data3 data4 Data Table 2 idOfTable1 col3 col4 t1 …
Gaps and Islands Months only
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 …
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 = ‘…