Advanced T-SQL Query

  • Hi,

    I am practicing in Advanced T-Sql , i mean Nested Select statement.

    can anybody knows the resource or forums,URL or book to get more practice

    on Advanced TSQL query.

    Please, let me know.if you have

    Thanks and Best Regards,

    Jignesh Patel

  • IMO your best bet would be to just try researching your particular solution's needs, instead of trying to find a book on the topic.

    Though you should probably try to avoid using nested SELECT statements. Performance-wise, that's rarely a good idea. You might want to look into using the Cross Tabs idea. Jeff Moden posted a pretty good article on it, though you could certainly find others. Here's the link: http://www.sqlservercentral.com/articles/T-SQL/63681/[/url]

  • I guess it depends on what you mean by "nested select statements".

    Are you using derived tables?

    select *

    from

    (select Col1, ColA

    from Table1

    inner join TableA

    on thisthattheother) as DerivedTable;

    Do you mean inline correlated subqueries?

    select (select Col1 from Table1 where ID = TableA.ID)

    from TableA;

    Or do you mean something else?

    As far as advanced T-SQL goes, I found Paul Nielsen's "SQL Server Bible" books to be quite good for getting a grip on those, and then just dig into MSDN or Books Online.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi are you looking at sub queries? for example

    select col1,col2,col1

    from sometable

    where col1 in (select col1 from someother table

    ***The first step is always the hardest *******

  • Hi Guys,

    You all, getting right..

    I am looking for Subquery, Derived Table, Correlated Query.

    you have any good article,or tutorial.Please let me know..

    Thanks and Best Regards,

    Jignesh Patel

  • instead of subqueries google temp tables, i prefer to create a temp table and then innner join instead of using subqueries

    however, it can depend on what you are trying to achieve

    ***The first step is always the hardest *******

  • jkp2311 (7/12/2011)


    Hi Guys,

    You all, getting right..

    I am looking for Subquery, Derived Table, Correlated Query.

    you have any good article,or tutorial.Please let me know..

    Thanks and Best Regards,

    Jignesh Patel

    Jignesh,

    I would try Google on some of these. I just check for derived table and what came up had some links that were very simple to understand and gave some good examples. I'm sure you could get the same for correlated subquery, subquery, etc.

    Put your attention on understanding the simplicities of these types of SQL uses. None of them are hard to understand. Make sure you understand all of the words in the explanations. Dream up some uses for them in the Adventureworks database and try them out.

    That's pretty much how I learned SQL. Just get a grasp on the basics and use them.

    Todd Fifield

  • Thanks to all

    for your kind supprot.

  • glen.wass (7/13/2011)


    instead of subqueries google temp tables, i prefer to create a temp table and then innner join instead of using subqueries

    however, it can depend on what you are trying to achieve

    And I also found this to be much quicker in my data warehouse.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply