Forum Replies Created

Viewing 15 posts - 5,386 through 5,400 (of 7,597 total)

  • RE: Date Range Formula

    Lynn Pettis (2/3/2015)


    ScottPletcher (2/3/2015)


    Best is to always use >= and < on date/datetimes, not between:

    SELECT DOC_NO

    ,ENTER_DATE

    FROM SALES_ORDER

    WHERE ENTER_DATE >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 12, 0)

    AND...

  • RE: Date Range Formula

    Best is to always use >= and < on date/datetimes, not between:

    SELECT DOC_NO

    ,ENTER_DATE

    FROM SALES_ORDER

    WHERE ENTER_DATE >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 12, 0)

    AND ENTER_DATE < DATEADD(DAY,...

  • RE: Please help with this query

    Again, you need to explain "lev5" to us. We do not know your data.

  • RE: Please help with this query

    You have to remember that I do not know what your data is.

    GROUP BY a.bf_fund_cd, a.bf_bdob_cd, b.lev5,b.bf_orgn_cd

    ...

    SS_21111_1 -Lev5 (dont need to show) ---> less than 5,000000

    SS_21112_2 -$1,500,000(dont need to show)

    SS_21113_2...

  • RE: Please help with this query

    If you want to see all values, remove the "having" condition:

    having sum(a.data)>5000000

  • RE: declaration

    Rather than use a specific ending value, most people prefer to use < the next day. That method always works, even if the date/datetime format changes later, something like...

  • RE: How to select decimal type field

    You'll have to use varchar output rather than a numeric format:

    SELECT REPLACE(CAST(pay AS varchar(30)), '.000', '') AS pay,

    ...

    FROM table_name

    WHERE ...

    ...

  • RE: What's the best way to setup these 2 databases?

    The internet site needs to be able to function stand-alone. You could periodically push data from the intranet to the internet db(s), but you don't want the internet db...

  • RE: sum result type character

    You can use sp_executesql, something like this:

    DECLARE @WIDTH decimal(19, 2)

    DECLARE @LONG decimal(19, 2)

    DECLARE @RESULT decimal(19, 2)

    DECLARE @sql nvarchar(4000)

    SET @sql = N'( @WIDTH / 3 ) + ( @LONG / 100)'

    SET...

  • RE: 'sys.dm_db_index_physical_stats' giving 3 rows with different fragmentation.

    Since the page count is vastly smaller, I would think it's the highest level of the index rather than the lowest (leaf) level.

    But you should definitely change the query to...

  • RE: How to speed up purge process

    Yeah, not bad, although it does have to do a full index scan for trans date on the TD table.

    You can do minor tweaks on the list itself, changing it...

  • RE: How to speed up purge process

    Ken Davis (1/30/2015)


    Scott, the Transactions table is the parent and ID is its primary key and clustered index. ID is the foreign key in TransactionDetails pointing to Transactions so...

  • RE: How to speed up purge process

    Is the TabletAuditLog.dbo.TransactionDetails table clustered on ID first?

    Just to confirm, the "ID" in the TD table is the same value as the ID in the T table, right?

  • RE: Help with query - Find recovered customers

    SELECT CustomerNumber,

    SUM(CASE WHEN [YearMonth] BETWEEN 201401 AND 201412 THEN TotalAmount ELSE 0 END) AS Sales_2014,

    SUM(CASE WHEN [YearMonth] BETWEEN 201201 AND 201312 THEN...

  • RE: Problem with a query with join and SUM

    This should give you more accurate totals, although it will list every combination of ProductionLine and Category, which may not be what you want.

    SELECT D.Line AS Line, D.ProductionLine AS ProductionLine,...

Viewing 15 posts - 5,386 through 5,400 (of 7,597 total)