Forum Replies Created

Viewing 15 posts - 676 through 690 (of 2,452 total)

  • RE: Record Matching FIFO to ignore any sale transaction before a buy or no inventory

    so what results would you expect from here.....(earlier post was not the sample data I intended posting...sorry)

    CREATE TABLE #BuyData(

    [Party_Code] [varchar](10) NULL,

    [Item] [varchar](20) NULL,

    [TradeDate] [smalldatetime] NULL,

    [PurchaseQty] [int] NULL,

    [Tsrno] [bigint] IDENTITY(1,1) NOT...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Record Matching FIFO to ignore any sale transaction before a buy or no inventory

    I am confused and I think your sample data may be over simplified.

    kudos for the set up data though...it helps a lot.

    what would you expect in this sample data?

    CREATE TABLE...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Does T-SQL have a means of iterating over the columns of a table?

    Sergiy (5/9/2016)


    R.P.Rozema (5/9/2016)


    Even though the solution presented here has serious limitations (and I think serious flaws too),

    I wonder who can see more of them - me or you? 🙂

    I...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Solution TSQL Help!!!

    some sample data and expected results would help me thinks

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    drew.allen (5/16/2016)


    J Livingston SQL (5/15/2016)


    maybe....use following and then do a crosstab

    WITH cteprices as (

    SELECT itmId,

    price,

    ROW_NUMBER() OVER(PARTITION...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    drew.allen (5/16/2016)


    J Livingston SQL (5/15/2016)


    maybe....use following and then do a crosstab

    WITH cteprices as (

    SELECT itmId,

    price,

    ROW_NUMBER() OVER(PARTITION...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    just to remind you again....without any columns to order your prices by, you are leaving yourself open to report the wrong results.

    making an assumption today. that prices will for now,...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    maybe...

    DECLARE @prices TABLE (

    itmId int,

    price money

    )

    INSERT INTO @prices VALUES (1, 1000)

    INSERT INTO @prices VALUES (1, 1500)

    INSERT INTO @prices VALUES (1, 1800)

    INSERT INTO @prices VALUES (2, 2000)

    INSERT INTO @prices VALUES (2,...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: need to create a result from two rows

    maybe....

    SELECT FromDate,

    ToDate,

    MAX(CASE

    ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: need to create a result from two rows

    randyetheridge (5/16/2016)


    I have a table that has daily rates for various currencies in multiple rows. i.e. eur to USD for 1/1/2016, Eur to CAD for 1/1/2016 etc. I am...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    maybe....use following and then do a crosstab

    WITH cteprices as (

    SELECT itmId,

    price,

    ROW_NUMBER() OVER(PARTITION BY itmId ORDER BY...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    well you could use ROW_NUMBER to do that....but what happens when a price drops?

    what you suggest will only work if proces are continualy increasing.

    I find it very hard to believe...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: summary query for difference between rows and %

    do you have anything in your prices table that indicates order....eg datetime / Id ?

    I think you need that to determine which price is Price1/Price2/ etc

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: SQL Query Question

    does seem a little like homework.....hmmm

    anyways and only because I have been playing around with converting screen grabs into usuable create table statements.....

    ----http://www.sqlservercentral.com/Forums/Topic1784995-391-1.aspx

    CREATE TABLE #Finance(

    PID ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Question about how Lag function will work on Sql server 2012

    zahid.techk (5/14/2016)


    Set DateFormat DMY

    Select DATENAME(MM,TransHdr.TransDate)As Month_Name,--(It Shows Only Months Name)

    Count(TransHdr.TransNum) As Total_Test,

    LAG(TransHdr.TransNum,1,0)As Prvs_transaction-- Over (Order by Month(TransHdr.TransDate)) As Prvs_transaction)

    ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

Viewing 15 posts - 676 through 690 (of 2,452 total)