TechSapphire Sunday, 2018-11-18, 11:03 AM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • Main » 2014 » December » 21 » Subquery or Sub Queries in SQL
    8:32 PM
    Subquery or Sub Queries in SQL

    Sub Queries-


    Three basic rules only.

    Where you can place sub query?
    3 places where you can place your sub query:
    SELECT ----- FROM
    FROM   ----- WHERE
    WHERE  ----->

    SELECT ----- FROM
    _____________________
    (sub query can only return single value & no alias to value returned is required)

    Correct:
    _________

    (select max(val) from abc where ---) Ex output: 10
    (select top 1 val from abc where ----) Ex output: abctext

    Wrong:
    _________
    (select val from abc where ----) and result is returning multple rows:

    Ex. ouput of above query:
    val
    ___
    12
    32
    45
    6
    45

    Click here to view complete article

    Category: Database | Views: 3799 | Added by: Admin | Tags: correlated subquery, sub query, subquery, sql server 2008, QUERY, sql, sub queries | Rating: 0.0/0
    Total comments: 0
    Only registered users can add comments.
    [ Registration | Login ]
    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2018