I’m looking for a query where I need to show all the Suppliers from the Suppliers table that doesn’t have products from category 1 (Products.CategoryID = 1). Whenever I run it it always gives an error. Side question: How do I get these results but with suppliers that has products from cat. 6 ? (So…
Tag: sql
Put a json inside another json on Oracle 19
i have the next problem. I need create a json from a table that contain another json inside in one of the columns Having this: i try with this query: But the result is not correct: Must be something like: There is a way to get the correct result? Regards. Answer after see examples and see the resuslts. I know
Is there other option to check if a table is in a SQl connection , Im trying to use dialect.has_table
Im getting this error : AttributeError: ‘Engine’ object has no attribute ‘exec_driver_sql’ Answer Nowadays the preferred method for performing such reflection is to use inspect:
Count occurrence of digits and using a case expression in a stored procedure
I want to write a stored procedure that displays the level of activity that an author has when it comes to create posts on a blog. I want to input a username in the call statement like call activity_level(‘Ugrob’); and get the following result nickname level_activity aupo_auth_id author_id time_po…
Is there a flexible way to specify ranges of dates?
I am working with MySQL. I have some queries that begin like this: I also sometimes need to run the same query, but with each date range being a week (Monday to Sunday), or a calendar month. Moreover, sometimes there are 100 or more of these, which is quite prone to typos in addition to occupying a lot of lin…
Sql – Calculate Inventory Days
I’m trying to calculate inventory day’s over time. I have an issue getting the actual amount of day’s in inventory for the last month. So as for the first row, the 9 days is correct. However the second row should show 34. Since I want to calculate the days between Inv_date and “today&#…
Retrieving the distinct count across multiple columns
Say I have the following table in MS SQL Server: Make Model Year Honda Accord 1997 Honda Accord 1997 Honda Accord 1997 Honda Civic 2001 Honda Civic 2005 Honda Civic 2005 Toyota Corolla 2010 Nissan Pathfinder 1997 I want to be able to retrieve the count for the unique combination and get the results like the f…
SQL – WITH RECURSIVE doesn’t work, when there is another query before
I have a (postgresql) query, that goes like This works perfectly fine. But when I reorder the with queries to that it suddenly shows a syntax error. This behaviour doesn’t occur, when I have standard non-recursive queries. With non-recursive queries, I can order them, as they please me. Why does it do t…
SQLite Database not getting updated
So Ive created an app where the user can input details about the movies he has watched such as name,cast,rating…ect and the details are stored in a database inside a table names which is initialized in the DataBaseHelper class as in the below segment of code Ive created a list view and displayed the nam…
Select longest word from a string SQL
Let’s say that I have a table with 2 columns: name and number. Name is a string which can have one or more words and I would like a new query with select name number but that in the name column it only has the longest word of the original table. Is there a function in SQL that extracts from