Skip to content

Tag: sql

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:

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…

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