I need to count the number of dates with which the invoices are made to certain customers in each month Consider the table named Table1 I tried the folllowing code and the result was The result I need should count the column named branch based on column month, the desired result is Here rowcount is based on b…
Fail SQL query if there is at least one wrong record in any of 3 tables (wrong means rate column<=0)
I have 3 tables and I need to check if they have a positive number in the “rate” column. Tables have different schema but they all have a column named “rate”. I am working with …
Get last row per group in SQL
I have the data below, and i want to get the last row per desc the result should be like this: how can i do it in SQL, please note that database is oracle. Answer You can get the expected result with the following query:
How to split one column with array merge value to array and join other table then merge back
There’s a table WaitCheckBil like : and a table Users like : Expected result : What I’ve tried & think : It’s a old system’s table , so I can’t change the struct. And the table logic is select * from WaitCheckBil where usrs like ‘%;’ + @usr + ‘;%’; to …
DB2: I want to see € or $ in the output of select
This simple query satisfy me db2 => SELECT city,SUM(sales) as sum from offices group by city; CITY …
Delete xml node with a specific CDATA
This is part of my XML: I need to delete the EO node with <![CDATA[0001FFFFFFFF]]>,across the table using Oracle. This xml is stored in XM_DATA_CACHE of XMLTYPE. Is there a way to delete based on CDATA Final output should be Answer First of all your xml is broken: second tag GoalMeasurementEORow is not …
How to group data if difference between rows is mothe than 1 minute
Im trying to create a new table on SQL which will have summarized data. For example. In the original table i have this data: If you see rows 9, 10 and 11 they are consecutive, so i want to group them …
Postgresql, one function calls another function and get 2 out values to caller
Postgresql 12. Want to call function testA() from another function testB(), and assign two “out” values to the 2 local variables. Don’t know how to do the assignment, please help. create or …
Postgresql – Select in Select Alias Problem
I have query. https://dbfiddle.uk/?rdbms=postgres_12&fiddle=1b3a39357a5fe028f57b9ac26d147a1d SELECT users.id as user_ids, (SELECT ARRAY_AGG(DISTINCT CONCAT(user_has_bonuses….
Query puzzle – how can I select values with fallbacks?
I have a table with 6 columns as follows: CREATE TABLE `test_table` ( `id` bigint UNSIGNED NOT NULL, `A` varchar(255) NOT NULL, `B` varchar(2) NOT NULL, `C` varchar(50) DEFAULT NULL, `D` …