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...

  • RE: Join To Same Table Question

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

  • 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...

  • 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/

  • RE: Can I reuse CTE ?

    Yes, a table variable would in deed be faster.

  • RE: Can I reuse CTE ?

    [p]WITH

    problem (problem_name, kount)

    AS (SELECT

    problem_name = pr.name

    ...

  • 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.

  • 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.

  • RE: Looping in T-SQL

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

  • RE: Looping in T-SQL

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

  • 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...

  • 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.

  • 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...

  • 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...

  • 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,...

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