I have table structure like below id |parent|value 1 | 0 | a | 2 | 1 | b | 3 | 4 | c | 4 | 0 | d | 5 | 0 | e | I want to display only rows that have a relation parent child like:…
How to optimize MySQL select query or make it faster
I have a select query, that selects over 50k records from MySQL 5.5 database at once, and this amount is expected to grow. The query contains multiple subquery which is taking over 120s to execute. …
Extracting data from JSON field in Amazon Redshift
I am trying to extract some data from a JSON field in Redshift. Given below is a sample view of the data I am working with. I am able to extract data for the first level namely data corresponding to fileFormat and data as below: I am trying to extract information under data like name, age,dateofbirth Answer Y…
How to select titles that are like the first n characters of a string?
Here’s an example There are titles of some animes: And I’d like to select those titles, that contain the first 10 character of the first record, so “My Hero Academia” in this example It’s important that it must be the first N characters, like 10,15,20. So SELECT title FROM tablen…
How to insert multiple rows in a SQL Database
I’m developing a Recipes Book and I’ve a problem saving multiple Ingredients for the same Recipe in the database. I can add, pressing a button, multiples Linear Layout with inside an ingredient …
Dynamic SQL Select variable name
I have the following SQL statement, which works fine: DECLARE @TableName VARCHAR(250); SET @TableName = ‘TBL_Name’ SELECT QUOTENAME(@TableName) As TableName, HASHBYTES(‘SHA1’, (SELECT * FROM TBL_Name …
SQL: Selecting all tuples which contain a certain value in a column after using count
I have the following table called Stores: Name | Category | Industry ABC appliances retail XYZ banking finance NZE clothing retail JKI …
How to aggregate count of rows having the same value in a sequence?
I have a query that returns data in the following sample: SELECT timestamp, atm_id FROM TRANSACTIONS ORDER BY TIMESTAMP ASC; Output TIMESTAMP | ATM_ID | ——————– 2010-01-01 | EP02 | …
SQL query to convert no. of rows to no. of column in oracle
I need to convert all rows into columns i.e. no.of columns= total no. of values in col2 and col3 related to col1. Scenario Query tried: How can I write a pivot query here? Answer use row_number() and conditional aggregation
How to find duplicates from Unique code column and delete the rows they’re attached too, while still keeping the original row?
I have a table in my azure sql server named dbo.SQL_Transactional, and there are columns with headers as code, saledate, branchcode code is my primary key, so if there is ever 2 or more rows with the …