SQL – Filling Gaps Between Dates

Let´s imagine a situation that you have a small market in which you have the inventory stored in a database table. In this table we have the date, the product code and the quantity available, but we don´t have the information for all days. The information in the tables refers only to the days the … Continue reading “SQL – Filling Gaps Between Dates”

C# – Create Your Own Report

Sometimes you have a lot of things to do, but you don´t have the means for that, so you will have to create your own means. We will apply this “philosophy” to present the data you have in your database, but you don´t have access to any reporting tool. In this case, we will create … Continue reading “C# – Create Your Own Report”

Python – Querying data from SQL Server

In this post we will work on a database connection using python. It´s very simple, let´s see how it works! Obviously you need the python installed on your system. For this exercise I am using verson 3.9.2. On the database side, we are using a table from Microsoft SQL Server with sales information. Although there … Continue reading “Python – Querying data from SQL Server”

SQL – CREATING A PROCEDURE TO CREATE TABLES DYNAMICALLY

This is just an exercise of how to work with dinamyc SQL inside procedures. This one is a very simple example of how create a procedure that will create objects according to the information that you will provide, in this case it will be a table. The procedure will receive two parameters: 1) The table … Continue reading “SQL – CREATING A PROCEDURE TO CREATE TABLES DYNAMICALLY”

SQL – Creating Rankings On Existent Categories.

Let´s say that you are the CEO of a big chain of supermarkets, you know what are your best departments and your most profitable stores, but you would like to know what are your top 5 departments by store. Sales by Stores and Departments TOP 5 Departments It´s very simple to know what are the … Continue reading “SQL – Creating Rankings On Existent Categories.”

SQL – Updating a table using another table

This case is when you have data in one table that needs to be corrected with data from another table. It´s very simple, you can solve this problem with a small query, with a minimal cost for the database. Considering the case that you have two tables, one with the informantion of the department ( … Continue reading “SQL – Updating a table using another table”

SQL – Bringing results from different dates in different columns

Let´s say that you have a table with two columns (one for date and other for sales amounts) from which you need to sumarize the sales amounts by WEEK, MONTH, SEMESTER and YEAR. In this post you will see how do that easily, without subqueries and cheap for the database query processor. The data in … Continue reading “SQL – Bringing results from different dates in different columns”