Forum Replies Created

Viewing 15 posts - 901 through 915 (of 1,183 total)

  • RE: Using Top(n) with CTEs

    WITH yourCTEname

    AS

    (SELECT

    CustID

    ,MAX(OrderDate) AS [Last Order]

    FROM Orders

    WHERE CustID

    GROUP BY CustID)

    SELECT

    ID,

    CustName,

    FROM Customers

    LEFT JOIN...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Join To Same Table Question

    ....but something tells me there's an easier way.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Join To Same Table Question

    Include another set of joins...

    SELECT

    pr.parentprodnodeid

    ,pr.childprodnodeid

    ,po.prodnodeid

    ,pc.sysclassname AS [Parent Class]

    ,cc.sysclassname AS [Child Class]

    FROM

    productrelationships pr

    LEFT JOIN productobjects po

    ON pr.parentprodnodeid = po.prodnodeid

    LEFT JOIN productclasses pc

    ON po.prodclassid = pc.prodclassid

    LEFT JOIN productobjects co

    ON pr.childprodnodeid...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Recommendations for a Good Report Manager Book

    The "Hitchhikers Guide to SQL Reporting Services 2000" is a great book. Although it's for 2000, a lot of it is still applicable.

    http://www.sqlreportingservices.net/

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Can I reuse CTE ?

    Yes, a table variable would in deed be faster.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Can I reuse CTE ?

    [p]WITH

    problem (problem_name, kount)

    AS (SELECT

    problem_name = pr.name

    ...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Can I reuse CTE ?

    Well, poo! I wasn't thinking of it that way. Of course, if you need info from both CTE's then you'll need to join them in the last select.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Can I reuse CTE ?

    No, CTE's are only available to the statement immediately following them.

    you will want to use a table variable instead.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Looping in T-SQL

    But I like random, it's rather difficult to disprove random results... :hehe:

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Looping in T-SQL

    Change "transactionDate" to "Spend DESC" in my code and you should get what you need.:D

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Looping in T-SQL

    First you want to get away from procedural thinking. SQL works best set based. Also, post the DDL for your tables, it makes it easier for people to respond with...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: add summary row to the pivot table

    Andras is correct. And easy way to do this would be to throw your PIVOT into a CTE and then you can call it twice in the union.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: countrows function?

    You simply put the name of your dataset or group in place of SCOPE. This will return the number of rows in the dataset or group. You do not need...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: tallying values in columns of each row

    It's a little confusing. I'm still not 100% on them (pivot and unpivot) but it's beginning to get clear. DONT ASK ME TO EXPLAIN.. *laughs*

     

    But as you can see the...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • RE: Cross Join

    Simply put, each row from one table is returned with each row from the second or a Cartesian Product is the result set. So if each table has 10 rows,...

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg

Viewing 15 posts - 901 through 915 (of 1,183 total)