I am using pyodbc to fetch total quantity of a product based on a certain criteria called “Strength”. The “Strength” column also has string value for some records, so it is a varchar column. The user enters details like brand, product type, product line, date range, minimum quantity (in this case, 12), and strength range This is my query: This
Tag: where-clause
How to select by two fields using IN operator
I tried query like SELECT id FROM events WHERE iid = 2 AND target_id = 3 OR iid = 3 AND target_id = 5 OR… How to short this? Also tried to use IN operator but it get wrong logic SELECT id FROM …
How to select different values in a column with the same ID and then delete them PHP SQL Server
I am new to the world of programming. I am in need of help in this sentence. what I want to do is select the 0.1,2 values from the CardIndex column and then be able to delete them. Rows must be removed as long as the condition is met. Or what would be the best way to do it. CardIndex
Trying to update where clause to only apply to a certain value
I have a stored procedure in my database. It is a dynamic piece of code and runs for multiple different parameters. Let’s say I have a parameter called @Param that gets passed: 17 (this parameter will be different for different processes). In my query I am attempting to use this parameter to update the WHERE clause like this: Does code
SQL query cannot use NOT LIKE to get results
I am starting out in SQL and am trying to do a query that will select all event names that are unique and do not have ‘TODAY-XXXXXXXX’ in the value for the event_name column. I have a query that works …
SQL JOIN with WHERE condition when two rows’ values are the same and one row matches to two different rows
I have these tables: CREATE TABLE students( id int NOT NULL PRIMARY KEY, name VARCHAR(30) NOT NULL ); CREATE TABLE studentsActivities( studentId int NOT NULL, activity VARCHAR(30) NOT NULL, …
Lag() function with WHERE clause
I have this sql function that works properly: SELECT out_hum , (out_hum – LAG(out_hum, 1) OVER (ORDER BY id)) As dif FROM excel_table But I want to select all the out_hum when the diferrence (dif) …
Get items from next week
I was starting to do a query such as: The problem with this is that items from previous years will also show up here. What would be the best way to do this query — I’m hoping I can still use an index on the query on the date_inserted field, which is why I’m asking this here Answer I would
Aggregate function not accepted inside WHERE clause
I have the following command. With this PostgreSQL schema. After adding AND day_of_week=3 to WHERE I get the following error. Why cannot I restrict this column? Answer You cannot use a derived column in a where clause. A simple solution is a lateral join: Some advice: Do not use NATURAL JOIN. There is nothing “natural” about it, because it does
IBM Maximo Where Clause
I am trying to create a where clause to return all work orders between set dates where the there are no ACTUALS recorded (no labtrans). I have an existing WC which i am using as a template for this one but i am stuck with the “where” element. Many Thanks, G Answer The easy way, trusting that the rest of