Skip to content

Bind where clause to a column

Input: When Process ID = 610 ID Value 50 2 60 16 // 2 80 128 I have two separate queries that fetch two values from the same table so I am trying to merge them together instaed of calling the table twice. When this is run the where clause applies to [value1] and nothing is set for [value2] I

Dense_Rank does not work as it is expected

I’m creating a query where I need to get the ranking depending on how many are duplicated in the column “MacAddress”(amount) in the table MacsUsers, this is the data: this is my SQL query: I think I’m doing well with the DENSE_RANK function but it does not work as it is expected, any p…

Identifying specific changes via audit table

I have an audit table in a SQL database that is structured like the one below: audit_id id location location_sub location_status dtm_utc_action action_type 2144 2105 9 1 1 2022-09-08 12:36 i 4653 2105 9 1 1 2022-09-08 13:53 u 7304 2105 10 2 2 2022-09-13 15:51 u 7326 2105 11 1 2 2022-09-14 10:06 u I’m tr…

How to use INNER LEFT instead of EXCEPT?

I read that MySQL does not support EXCEPT, and the workaround is to use LEFT JOIN. THIS IS MY QUERY: Basically: Trying to find out the manufacturers that sell PCs but not laptops. How can I convert this query with the LEFT JOIN? I got confused.. Table Computers: Table Manufacturers Computers: So since Manufac…

SQL dynamic output tables

right now I have 2 tables. The first one has all the sales done by sales persons throughout each week, this table updates every week and only displays the sales of the current week (erases the data and starts over next week), the second table is a record of all sales done ever. SALES FOR THIS WEEK OCTOBER(9 T…

Condition Based Join in SQL Server

I have the following tables Invoice Organization Customer I’m trying to conditionally join these tables by the following condition: If PTypecd = ‘I’ then data come from the Customer table And if Ptypecd = ‘O’ then data come from the Organization table into the Invoice table. the …

Field contains or is equal to another field

I am trying to write a query to return results where “Column B” is equal to or contains “Column A”. I need both, because some fields in Column B are an exact match for field in Column A, and sometimes the value in Column B is the value from Column A with additional characters added on …