Skip to content

ShalomAndre/ConsultasSql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Desafio de SQL: Resolvendo Problemas do Mundo Real

Objetivo

Desafiar as minhas habilidades resolvendo perguntas reais de entrevistas de SQL de grandes empresas de tecnologia, como Microsoft, Airbnb e Linkedin, usando a plataforma Stratascratch. É a melhor forma que encontrei para me preparar para entrevistas técnicas e destacar as minhas competências em SQL.

Habilidades Aprendidas

  • Resolução de problemas de SQL.
  • Adaptação a perguntas reais de entrevistas de empresas renomadas, como Microsoft, Airbnb e Linkedin.
  • Aprofundamento das competências em SQL.
  • Preparação eficaz para entrevistas técnicas.
  • Destaque das habilidades em SQL perante grandes empresas de tecnologia.

Ferramentas utilizadas

  • Plataforma Stratascratch.
  • SQL.
  • Microsoft SQL Server (T-SQL).

Passos

  1. Admin Department Employees Beginning in April or Later

Find the number of employees working in the Admin department that joined in April or later.

SELECT
    COUNT(*) as num_admin
FROM
    worker
WHERE
    department = 'Admin' AND MONTH(joining_date) >= 4;

Resultado - Exercício 1

  1. Customer Revenue In March

Calculate the total revenue from each customer in March 2019. Include only customers who were active in March 2019.

Output the revenue along with the customer id and sort the results based on the revenue in descending order.

SELECT cust_id, SUM(total_order_cost) AS revenue
FROM orders
WHERE MONTH(order_date) = 3 AND YEAR(order_date) = 2019
GROUP BY cust_id
ORDER BY revenue DESC

Resultado - Exercício 2

  1. Ranking Most Active Guests

Rank guests based on the total number of messages they've exchanged with any of the hosts. Guests with the same number of messages as other guests should have the same rank. Do not skip rankings if the preceding rankings are identical.

Output the rank, guest id, and number of total messages they've sent. Order by the highest number of total messages first.

SELECT 
    DENSE_RANK() OVER(ORDER BY SUM(n_messages) DESC) as rankings, 
    id_guest, 
    SUM(n_messages) as sum_n_messages
FROM airbnb_contacts
GROUP BY id_guest
ORDER BY sum_n_messages DESC

Resultado - Exercício 3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published