I am using below SQL query to count the records. I would like to discount the duplicate testID after I got the count. example: select COUNT(*) from PRODUCT where CLASS_TYPE = ‘test’ above query …
How to get the part of a string after the last occurrence of certain character?
I would like to have the substring after the last occurrence of a certin character. Now I found here how to get the first, second or so parts, but I need only the last part. The input data is a list of file directories: Unfortunately this is the data I have to work it, otherwise I could list it using
SQL return max in unnest
I have the following query: What should I do if I only want the query to return one array.col1 per row in table_a (let’s say I want only the max value for each case)? Answer You can use a subquery:
Stop Printing double values SQL
Hello Guys! Oracle SQL I am trying to find a way to stop my sql Query print duplicate values. For example Results coming for a table are: The result I want: Thanks in advance! Answer Use DISTINCT to remove duplicate values :
Inserting a value in particular cell of DB2 blu table
I want to insert a value in a column “column_1” of table “table_1” with a condition where column “column_2” has a particular value and column “column_3” value is not like some value. “column_2” and “column_3” are both in the same table “table_1”. I tried the following query but I am not getting require result. INSERT INTO Table_1 (Column_1) VALUES (‘Distribution’)
SQL trying to use a column from a joined table in a subquery
Here is what I currently have which returns 3 columns for patient_id, group_concat_1, and group_concat_2: However, I need to return a single column with group_concat_1 and group_concat_2 combined, so I tried this: But his clearly doesn’t work since now it can’t find patient.id in the inner subquery. Any advice? Thanks! Answer You can concatenate directly the 2 columns:
Create columns with the frequency of a code per ID
I have to perform a query where I can count the number of distinct codes per Id. The output should be something like: Can you give me some advise on this? Answer Use conditional aggregation:
How to loop multiple form input and assign into sql query in php?
Refer to comment in the function, how to achieve that output? the idea is, from the input POST i get which over 27 fields, i just want to fill in into the $sql query i prepared as you can see. I don’t think writing each table column manually is a good way. im using Codeigniter 4 php framework + postgresql.
Delete Operation Slows down intermittently oracle 11g
We have a audit Table in production environment where we delete almost 15 millions data everyday(data which is older than some days)in PL/SQL batch. On a good day this query takes 1.5 hours to delete …
How can I get the months between two dates in Oracle SQL
I need to get the numbers of the months between two dates. For example, between those dates: “03/03/2020 – 06/06/2020” I need something like “(03,04,05,06)”. Answer For Oracle: