Forum Replies Created

Viewing 15 posts - 166 through 180 (of 541 total)

  • RE: Running total error

    Eirikur Eiriksson (6/20/2014)


    Take a look at this article, How to Return Running Product Totals.

    I think the method I used earlier has already been posted on this thread, it is the...

  • RE: Running total error

    Eirikur Eiriksson (6/20/2014)


    Bear with me here but is this the result you are after?

    😎

    MyLongDesiredRunningTotalSequenceWK NOACCOMPUSD_AMOUNTSOA_TYPE

    100.00191620112003100.00Agent

    300.002101620412003200.00Freight

    450.003111620712003150.00Agent

    700.005121620812003250.00Costs

    1100.006131622412003400.00Cost

    1600.007141629512003500.00Freight

    2140.008151629512003540.00Cost

    Yes, this is exactly the result I am looking for. Could you please what query you...

  • RE: Running total error

    Sachin Nandanwar (6/20/2014)


    I dont understand the problem here.Your query seems to be achieving it.

    CREATE TABLE [dbo].[GL](

    [Sequence] [int] NOT NULL,

    [WK NO] [int] NULL,

    [AC] [nvarchar](10) NULL,

    [COMP] [nvarchar](10) NULL,

    [USD_AMOUNT] [numeric](16, 2) NULL,

    [SOA_TYPE]...

  • RE: Running total error

    ChrisM@Work (6/20/2014)


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

  • RE: Running total error

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

  • RE: Running total error

    Sachin Nandanwar (6/20/2014)


    Yes that's right..

    Could you please suggest another way to do a running total in SQL 2008 R2 then ?

    Thanks.

  • RE: Running total error

    Sachin Nandanwar (6/20/2014)


    Quote strange.Can you post the entire query.

    Please find the query attached.

    Thanks.

  • RE: Running total error

    Sachin Nandanwar (6/20/2014)


    Is this SQL 2005 and above ?

    EDIT: Whats the compatibility of the database ?

    Thanks.

    Yes, its SQL 2008 R2. The compatibility level is SQL Server 2008 (100).

  • RE: Running total in sql and additional issue

    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) +

    SUM(CASE...

  • RE: Where clause issue

    GilaMonster (2/27/2014)


    Ok, so the query fragment i gave earlier is correct, it was just short a clause.

    SELECT Booking_ID FROM dbo.BOOKING AS b

    WHERE DG_FLG != 'Y' AND

    NOT EXISTS (SELECT 1...

  • RE: Where clause issue

    GilaMonster (2/27/2014)


    pwalter83 (2/27/2014)


    What I wish to achieve is no rows should be displayed where DG_FLG = 'Y' and OOG_FLG = 'Y'.

    Which wasn't what you said in your initial post.

    What...

  • RE: Where clause issue

    GilaMonster (2/27/2014)


    Without table definition and usable sample data I'm guessing, but...

    WHERE NOT EXISTS (SELECT 1 FROM <Table Name> ib WHERE ib.Booking_ID = <outer table reference>.Booking_ID AND Flag = 'Y')

    If you...

  • RE: Include weekend hours in calculation

    djj (1/28/2014)


    How do you handle the fact that Saturday and Sunday do not have a place in the Staff table?

    That was my question if you read it properly. Resolved it...

  • RE: Include weekend hours in calculation

    Resolved it by myself.

  • RE: Include weekend hours in calculation

    no issues.

Viewing 15 posts - 166 through 180 (of 541 total)