Free cookie consent management tool by TermsFeed Policy Generator
  • Azure SQL
  •    2 page views
  • 2024, March 08, Friday

#017 Return only non-null rows in Azure SQL

Como retornar somente linhas não nulas 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 "erp. Collaborators" with a specific condition. I'll explain each part

of the code:SELECT
  1. Contributor, Admission AS FirstDay

    :
    • SELECT: Indicates that the next part of the code will specify which columns will be returned in the query.
    • Collaborator: This is the column that will be selected.
    • AS FirstDay Admission: Select the "Admission" column and rename it "FirstDay". Using AS allows you to rename the column in the query output.
  2. FROM erp. Collaborators

    :
    • FROM: Indicates the table from which the data will be selected.
    • erp. Collaborators: This is the name of the table from which the data will be extracted. The prefix "erp." suggests that the table is in a schema called "erp."
  3. WHERE
  4. Dismissal IS NOT NULL:WHERE

    • : Filters results based on a condition.
    • Dismissal IS NOT NULL: The condition specifies that only records whose value in the "Dismissal" column is not null will be included in the query. In other words, the query returns only employees who have been laid off.

Therefore, the code returns the employees and the date of admission (renamed to "FirstDay") from the "erp. Employees", but only for those who have been laid off, i.e. whose "Dismissal" column is not null. This query is useful when you want to get specific information about laid-off employees in an organization.

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

  • Reading time 1 min 12 seg

avatar
Fabio Santos

Data Scientist and Consultant for Digital and Analytics Solutions


  • Share

Youtube Channel

@fabioms

Subscribe now