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…
Tag: sql
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…
SQL join and Bring in 1 column into 2 columns
I have two tables shown as above. I want to create a select statement that would have the following result: Basically, I want to join on ‘Model’ and ‘Num’ columns and bring ‘Val’ vales but break it …
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…
avoiding write conflicts while re-sorting a table
I have a large table that I need to re-sort periodically. I am partly basing this on a suggestion I was given to stay away from using cluster keys since I am inserting data ordered differently (by time) from how I need it clustered (by ID), and that can cause re-clustering to get a little out of control. Sinc…
Amazon Athena returning “mismatched input ‘partitioned’ expecting {, ‘with’}” error when creating partitions
I’d like to use this query to create a partitioned table in Amazon Athena: Unfortunately I don’t get the error message which tells me the following: line 3:2: mismatched input ‘partitioned’ expecting {, ‘with’} Answer The quotes around ‘PARQUET’ seemed to be cau…
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 …