We Learn SQL #15 | SQL Subqueries in SELECT

Поделиться
HTML-код
  • Опубликовано: 25 авг 2020
  • We’re going to learn about SQL subqueries in the SELECT clause. Find out how to use them correctly and how it will improve your work with databases.
    If you want to learn or practice SQL, check out learnsql.com/.
    It is very important to remember that a subquery in the SELECT clause must return exactly one row with exactly one column. If it returns more than that, you’ll get an error, and the query won’t work. For this reason, this sort of subquery frequently uses an aggregate function such as AVERAGE or SUM because such a function aggregates the rows and returns exactly one value.
    Without further ado, let’s get started!
    👌 Subscribe to our channel and leave a comment!
    👌 Do you want to learn SQL? Go to LearnSQL.com and choose the course or track that is best for you!
    👌 Join us on Facebook: / welearnsql
    🔊 Music: www.bensound.com/
  • НаукаНаука

Комментарии • 11

  • @davidcorona644
    @davidcorona644 11 месяцев назад +3

    Great video! I just want to add that subqueries in the select statement are also referred to as 'subselects' and that a subselect query can reference columns in the select query. However, subqueries used in join cannot. Queries used in joins can also have multiple columns and are similar to a common table expressions (CTE). In SQL the only parts you need single-row unique columns are in: subselects and in where clause subqueries.

  • @lawngreenlyp
    @lawngreenlyp 2 года назад

    Thanks. Never learn this method before.

  • @Rafian1924
    @Rafian1924 Год назад +2

    Please lower down the volume of background music

  • @Priyankayadav-zt8ck
    @Priyankayadav-zt8ck Месяц назад

    What if we need column name , instead of aggregates ?

  • @simplemente_humano
    @simplemente_humano 3 года назад

    Thanks for the tutorial. Very helpful.

  • @michaelkoletsas7574
    @michaelkoletsas7574 Год назад +1

    legendary lad

  • @maheshmenta6078
    @maheshmenta6078 3 месяца назад

    thank u

  • @kamuranpeker132
    @kamuranpeker132 7 месяцев назад

    Teşekkürler dostum

  • @uc7602
    @uc7602 2 года назад +6

    The background music is very distracting. Unfortunately, it is difficult to hear and listen to the presented learning content. Please consider lowering the music by 90% or simply eliminate it. Thanks!

    • @charlotteharvey1457
      @charlotteharvey1457 Год назад

      I didn't find it distracting - but it didn't help me feel like I was understanding everything. I had to pause the video in several places to digest what it said - so the music was not useful because it also got paused

  • @user-rr5xv8tq9n
    @user-rr5xv8tq9n Год назад

    DECLARE @eighteen_months_ago DATE;
    SET @eighteen_months_ago = DATEADD(MONTH, -18, GETDATE());
    -- Convert the date to a VARCHAR in the format 'yyyy-MM-dd'
    DECLARE @date_string VARCHAR(10);
    SET @date_string = CONVERT(VARCHAR(10), @eighteen_months_ago, 120); -- 120 represents the 'yyyy-MM-dd' format
    -- Delete data from the table where 'date_column' is older than 18 months
    DELETE FROM your_table_name WHERE CONVERT(VARCHAR(10), date_column, 120) < @date_string;