I have data like this: Person A has a relationship with Person B, and person A has a relationship with Person C Person B has a relationship with D and E. I want to view result in group in SQL Server (A, B ,C,…) and (B,D,E,…) I have tried looking recursive but not getting this to implement. I need …
SQL query NOT EXIST very slow
I’m trying to optimize an SQL query as it is slow, and gets slower when the query result is high. There are indexes concerned fields and Tables are quite big. Answer As a starter, this condition: Should be rewritten as: This is functionally equivalent, and not using date functions on the column being fi…
Mysql: Update json column with values from different table/column
I’ve been trying to update the below neighbors column in location table as json object, as seen below, but cannot get this even remotely close to working in any way. Any idea on the query syntax? …
Correct way to get data for BIRT reporting
We have a system which contains 4 Hierarchies. 1. Senior Manager 2. Manager 3. Supervisor 4. Employee Data related to all these are stored in different tables with respective details. There is a single address table which contains address of all these hierarchies. Sample Data Set We would be able to do a coun…
Subquery to check date availability
Could you help me with finding a solution to my query problem? I am stuck with it already for a week so I decided to try to ask for help and learn something. I am using MySQL database. Right now I have a table without the “search feature”. This is the result: I want to show all rooms in the
Value from 2nd Row of column copied to 1st row of next column
The table looks like below. I am trying to make 1 new column say SuprerFrez whose value is depends on column FREQHZ. For every UVRID group 2nd value FREQHZ will be 1st value of SuprerFrez and for last FREQHZ, SuprerFrez value will be zero. Expected output with 1 new column whose value depends upon FREQHZ colu…
SQL Query to group by month and display individual month sum for a record
I’m trying to sum product codes with a particular description as total products sold in a month over the years. The two table used are: The date format is in ‘DD-MON-YYYY HH12:MI PM’. So far I’m able to formulate this: How do I separate the count as different month columns and get the …
Change date time format from YYY-MM-DD HH:MM:SS to YYYY.MM.DD HH:MM:SS in SQL Server
I have a table with a column RequestDate with following format 2019-12-01 00:00:00:000. I want to see results like this: 2019.12.01 00:00:00:000. I used this command From the above query I am seeing results as 2019.12.01, but I am missing time (00:00:00:000) – how can I keep along with time. I want fina…
PostgreSQL Generated Column from a JSONB column with nested values
I have following table with a JSONB column: CREATE TABLE movies ( contributors JSONB ); The data in the column looks like this: INSERT INTO movies (contributors) VALUES(‘[ {“last_name”: “…
How to sum and count in grouping in sql
I have tables like below. I would like to grouping and counting by referreing to its score. First, I would like to sum score by customer It achived by group by method. second, I would like to count by binning following band. I couldn’t figure out how to count after grouping Are there any way to achieve …