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
SQL. Join with filter and offset
I need to create a SQL query that will return images with tags. The result should be ordered by some column and filtered by UserID and tags. The result should be paginated. There is a SQL statement This request is not working as expected. I expect to get 50 images, but they will be combined with tags and the …
How to do an arithmetic operation with aliased column in SQL
I have a databse table as like below: Here, received_by and sent_by are two user ID those who are receiving and sending the product respectively. I want to calculate the total amount of each product of a single user by subtracting the sent amount from received amount. My current query looks like below: Here I…