Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question Sample Example – SELECT * FROM table_name FORCE INDEX (index_list) WH…
Tag: sql
SQL Query Challenge. Divide by Subquery returning ‘Subquery returned more than 1 value.’ error
I have the following table in which I have two sales orders and each sales order has a different number of transactions. SaleOrder Transaction Amount Tax Delivery Charge TotalTax (Including Tax of Delivery Charge) S1 T1 12 0 3 5.5 (This also includes Tax in Column 4) S1 T2 27 4 3 5.5 S2 T1 15 2.5 5 6 S2
Sqlite Query to remove duplicates from one column. Removal depends on the second column
Please have a look at the following data example: In this table, I have multiple columns. There is no PRIMARY KEY, as per the image I attached, there are a few duplicates in STK_CODE. Depending on the (min) column, I want to remove duplicate rows. According to the image, one stk_code has three different rows.…
mysql order by field row display even if empty
I’ve two tables( bom and bom_parts). Need to inner join and display stock_deduct,GRN_id,part_id fields. Table 1 (bom): Table 2 (bom_parts): MySql query: Query Result: Expected Result: Even if the part_id field is empty in this case 8, 6, I just want to display the part_id with the stock_deduct field as …
How to rewrite query NOT IN with join condition
Below query having high cost, dur to NOT IN (sub-query) I dont have idea how to rewrite the AND clm.column1 NOT IN(sELECT column1 FROM prod) with join condition. If have any idea, please let me know. Answer There are multiple issues in your query. I tried to resolve them as much as possible in following code:
MySQL : Calculate percentage composition based on a specific value
I have the following MySQL table named Table1 The Result can either be Pass or Fail. I want to calculate the percentage pass for each id. Result must be the following table based on formulae: For each id, count Pass / Total Counts for given id. For example id 2 have 2 pass and 2 fail therefore percentage pass…
How to correctly convert SQL rows to columns?
Before someone mentions it, I have seen the exact same SQL question on Stack before and from my point of view, that’s actually transposing columns to rows. What I’m trying to accomplish is as seen below in the photos, given the top one, I want to create a new table with the previous data that is f…
Convert a json which is a list of dictionaries into column/row format in Postgresql
I´ve a json which is a list of dictionaries with the next syntax: The json is really big and each dictionary have different amount of key/values fields. And what I want to do is to create a table in postgresSQL where the key represents a column and the value a row. In the example explained above I would like …
Why DB Browser have an order I can’t replicate?
I have an issue I really don’t understand. In fact, I have a database of movies where there’s a table for actors,containing two colums (movie id and name). For example, then I enter the movie id of …
Dynamic columns using pivot
I have a table that looks like this: Main table id bomname styleid 1 bom1 101 2 bom2 102 3 bom3 103 this is detail table Id bomId bomKey bomValue 1 1 part cllr 2 1 unit kg 3 1 qty 123 4 1 part body 5 1 unit kg 6 1 qty 456 7 2 part slm 8 2