Skip to content

Tag: sql

How to reduce SQL log file size

SQL log file size is very big in our production database and hard disk space left only 2G. Is it safe to delete .ldf file? Answer Check out this post In the interim, this should at least allow you to kill the log file: Perform a full backup of your database. Don’t skip this. Really. Change the backup me…

Showing computed and non-computed data in one column with SQL

I have an MS Access database that has several tables. Of these tables, I have a bin table that shows 84 bins with the bin numbers being the primary key. It has another attribute for TotalCapacity. I have another table for inbound tickets that contains an attribute that accepts a number for bushels of commodit…

Sqlite, using grouping? for subqueries with date ranges

I have a sqlite query that works as-is and it’s used to get an average of date between a date range Again, this works perfectly but I’d like to do some kind of subquery operation that does this same thing for every month and returns the result for each as a different alias like this but my issue i…

I can’t get around INNER JOIN in MySQL

I have two tables in my database. One of which is a table called players and the other one is bans: What I need to do is: select players that where reason = cheating and Score < 250. I tried doing some JOINS when I tried FULL JOIN I found that thing doesn’t exist in MySQL so any help would

efficient way to find last week customer

I have 3 columns(customerid, date_purchased, item) table with 2 weeks of data. I want to retrieve the customers that only bought from the first week. My logic is to find the max date subtract it all the rest of the dates and retrieve customers where that difference equal or less than 7. Here is what I did, bu…

How to bind variable in string in SQL query?

I am using SQL Developer. When I want to bind value. Normally I use following syntax: but, I don’t know how to do that in string. The following query does not work. Why do I need it? Because my program runs a query in python and assigns something to bind variable: Answer Concatenate the prefix/suffix wi…

date time comparison with > does not work

I have two SQL statements: 1) (now i use this) 2) (but i need to use this) first query return 11 lines query 2 return 388. my observation (about query 2) is that instead of “2019-11-26 13:20:00” it is taken “2019-11-26” and when I replace it really returns the same answer date_occured …