Forum Replies Created

Viewing 15 posts - 3,226 through 3,240 (of 10,144 total)

  • RE: Running total error

    pwalter83 (6/23/2014)


    ... I need to use the following query to get the desired resultset. I think that is where the problem is

    If the query you "need to use" doesn't work...

  • RE: Running total in sql and additional issue

    pwalter83 (6/19/2014)


    Sachin Nandanwar (6/19/2014)


    Something like this

    SELECT SUM(YourSum) FROM

    (

    SELECT SUM(CASE WHEN SOA_TYPE = 'Agent' THEN USD_AMOUNT ELSE 0 END) +

    SUM(CASE WHEN SOA_TYPE = 'Freight' THEN USD_AMOUNT ELSE 0 END) +...

  • RE: Help needed for a complex query.

    Are we good so far?

    DECLARE @fromDate DATE = 'Apr 01 2008'

    DECLARE @tODate DATE = 'Apr 30, 2014'

    DECLARE @NumberOfRecords INT = 6

    DECLARE @period VARCHAR(10) = 'monthly' -- (This can...

  • RE: Help needed for a complex query.

    KnowledgeSeeker (6/20/2014)


    Exactly.

    Good. You have some guesses - which is nice.

  • RE: update error

    Or:

    UPDATE t1 SET

    P = T.NewP

    FROM table_1 t1

    CROSS APPLY (

    SELECT NewP = ISNULL(MAX(p),0)+1

    FROM table_1 t2

    WHERE t1.link = t2.link

    ) t

    What can you tell us about the distribution of values...

  • RE: Running total error

    pwalter83 (6/20/2014)


    Sachin Nandanwar (6/20/2014)


    But you seem to having one already in your query

    (SELECT SUM(CASE WHEN SOA_TYPE IN ('Agent','Freight','Cost') or AC = '16208'THEN USD_AMOUNT ELSE 0 END) YourSum

    FROM...

  • RE: Help needed for a complex query.

    KnowledgeSeeker (6/20/2014)


    Sorry if the requirement is not clearly mentioned(English is not my first language). In the example I gave the dates the user passed are June 05, 2010 and June...

  • RE: Help needed for a complex query.

    KnowledgeSeeker (6/20/2014)


    No. The requirement is quite clear. If the user wants to find last 5 week's data from the table and he has the upper range for date say, June...

  • RE: Help needed for a complex query.

    KnowledgeSeeker (6/20/2014)


    I have a table with large data. The structure along with the sample data of the table is as follows:

    CREATE TABLE #SampleData

    (

    BaseYear INT,

    TransYear INT,

    ClientName VARCHAR(50),

    DepID INT,

    Revenue, INT,

    TransactionDate DATETIME

    )

    INSERT...

  • RE: Difference Between cross apply and cross join

    daniarchitect (6/19/2014)


    bitbucket-25253....wasted my time what a response

    If Bitbucket's explanation doesn't exactly meet your requirements, then simply ask what you need to know. Rudeness is unnecessary and unprofessional.

  • RE: Multiple ON Clauses In One Join?

    Eugene Elutin (6/19/2014)


    ...and the example was later extended for use as a TSQL recruiting test.

    have you ever tried asking on interview what kind of results the following statement will produce:

    SELECT...

  • RE: Multiple ON Clauses In One Join?

    autoexcrement (6/19/2014)


    What a fantastic explanation! Thank you so much for taking the time!

    You're welcome - but the time was taken a while ago to demonstrate a point to a colleague...

  • RE: Multiple ON Clauses In One Join?

    Eugene Elutin (6/19/2014)


    ...

    -- Query 4

    SELECT c.*, o.*, ol.*

    FROM #Customers c

    LEFT JOIN #Orders o

    INNER JOIN #Orderlines ol

    ON ol.OrderID = o.OrderID

    ...

  • RE: Multiple ON Clauses In One Join?

    This might help:

    “You have a query which joins two tables, say Customers and Orders. It’s an outer join because you want all customers whether or not they’ve ever placed an...

  • RE: display all data from row 1 but include sum total of all rows amount column in data set

    This might get you started:

    SELECT --DISTINCT

    t.transactionID, b.TransDate, b.TransType, b.TransDesc1, b.TransDesc2, b.TransDesc3, b.TransDesc4, b.TransDesc5,

    (b.Debit + b.Credit) as Amount,

    ISNULL(r.OrthoID, 0) as OrthoID,

    ISNULL(t.PatientID, 0) as PatientID,

    t.ledgerAmount,

    t.LedgerType,

    (b.Debit + b.Credit) -...

Viewing 15 posts - 3,226 through 3,240 (of 10,144 total)