Free cookie consent management tool by TermsFeed Policy Generator
  • Azure SQL
  •    10 page views
  •   0 video views
  • 2024, October 25, Friday

#035 Find the total amount of all sales for each day in Azure SQL

Como localizar a quantidade total de todas as vendas em cada dia em Consulta (SELECT) existente na linguagem de Manipulação de Dados (DML) do Azure SQL/SQL Server

This T-SQL code performs a query on the "f.Combustibleis" table. I'll explain each

part of the code:SELECT [
  1. DATE], SUM([VALOR_VENDA]) THE SalesDay

    :
    • SELECT: Indicates that the next part of the code will specify which columns will be returned in the query.
    • [DATE]: Select the "DATE" column.
    • SUM(
    • [VALOR_VENDA]) THE SalesDay: Calculates the sum (SUM) of the "VALOR_VENDA" column for each group of records based on the "DATE" column. The result of this sum is renamed to "SalesDay" for easy reference in the query.
  2. FROM
  3. f.Fuels

    :
    • FROM: Indicates the table from which the data will be selected.
    • f.Fuels: This is the name of the table from which the data will be extracted. The prefix "f." suggests that the table is in a schema called "f".
  4. GROUP BY [DATA]:GROUP BY

    • : Groups the results based on the specified column, in this case, "DATE". This means that the sum will be calculated for each distinct group of values in the "DATE" column.
  5. ORDER BY [DATA]:ORDER BY

    • : Sorts the results of the query.
    • [DATE]: Sorts the results based on the "DATE" column, in ascending order, i.e. from the earliest to the most recent date.
Therefore, the

code returns the sum of fuel sales grouped by date, and the results are sorted by date in ascending order. This query is useful when you want to analyze aggregate fuel sales over time.

This content contains
  • Content Imagem
  • Language Portuguese
  • Duration
  • Subtitles Não

  • Reading time 1 min 16 seg

avatar
Fabio Santos

Data Scientist and Consultant for Digital and Analytics Solutions


  • Share

Youtube Channel

@fabioms

Subscribe now