Forum Replies Created

Viewing 15 posts - 1,366 through 1,380 (of 1,496 total)

  • RE: Using Calculated Field/Case Labels in other Calculated/Case Fields

    You can do it via a derived table:

    SELECT

     D.UM

     ,D.UM_DIV

     ,D.UM_DIV * D.QTYORD AS UnitNum

    FROM (

     SELECT S.UM

      ,S.QTYORD

      ,CASE S.um

      WHEN 'ea' THEN 1

      WHEN 'bx' THEN 10

      ELSE 2 END AS UM_DIV

     FROM Sales S ) D

     

  • RE: 10 minutes stored procedure now runs hours and hours

    You could try checking to see if any of the VIEWs point to a different server.

    Also, as you do not seem to be using any aggregate functions, you could remove...

  • RE: Question on improving a query

    Using LEFT JOINs instead of INNER JOINs should solve your immediate problem. Age should always be calculated from DateOfBirth.

     

  • RE: join on beginning of field

    AMacKay,

    You really need to redesign your tables so that the <Customers> table has a PRIMARY KEY called something like customerID int. Then you will need to add customerID as a...

  • RE: Finding expiry and effective date from same column

    The following should work but, like all triangular joins, if you have a lot of rows it would be better to use a cursor. Somewhere between 5000 and 10000 rows...

  • RE: Transaction Locks

    Do the following test with UPDLOCK:

    1. Open Query Analyser twice selecting your db in both.

    2. In one copy of QA run:

    BEGIN TRAN

    SELECT MIN(serialNo)

    FROM card_pins WITH (UPDLOCK)

    3. In the other copy...

  • RE: Transaction Locks

    I think you need to use either an UPDLOCK or an XLOCK. An UPDLOCK should be alright here.

    SET XACT_ABORT ON

    BEGIN TRANSACTION

    SELECT @get_PIN = MIN(serialNo)

    FROM card_pins WITH (UPDLOCK)

    DELETE card_pins

    WHERE serialNo= @get_PIN...

  • RE: Maximum Count By days

    SELECT DATEADD(day, 0, DATEDIFF(day, CAST(0 as datetime) ,StartTime)) AS WorkDay

     ,COUNT(DISTINCT EmployeeID) AS MaxEmp

    FROM TimeClock WITH (NOLOCK)

    WHERE StartTime >= '20061001' AND EndTime < '20061101'

    GROUP BY DATEADD(day, 0, DATEDIFF(day, CAST(0 as datetime)...

  • RE: duplicate records

    SELECT username

    FROM usermaster

    GROUP BY username

    HAVING COUNT(*) > 1

  • RE: select reoccuring values only

    What you want is unclear. If the rows returned are exact duplicates then replace SELECT with SELECT DISTINCT, otherwise you will need to decide which EUS_ID row to return. eg...

  • RE: select reoccuring values only

    Maybe:

    SELECT L.LOB_ID

     ,L.EUS_ID

     ,L.LOI_START_DATE

     ,L.LOI_END_DATE

     ,E.CTY_CODE

    FROM learning_object_instances L

     CROSS JOIN end_users E

     JOIN (

      SELECT L1.EUS_ID

      FROM learning_object_instances L1

      WHERE L1.LOI_START_DATE > '20060907'

      GROUP BY L1.EUS_ID

      HAVING COUNT(*) > 1 ) D

     ON L.EUS_ID = D.EUS_ID

    WHERE E.CTY_CODE = 'RU'

     AND L.LOI_START_DATE > '20060907'

  • RE: Does Access lock source table during import?

    You may want to consider a different strategy:

    1. Create views for all tables and views in your db along the lines of:

    CREATE VIEW RO_YourTableName

    AS

    SELECT *

    FROM YourTableName WITH (NOLOCK)

    2. For your...

  • RE: Users and Isolation Level

    I think this can be done by creating a db that only consists of VIEWs of the tables in the main db. All the SELECTs in the VIEWs will have the...

  • RE: Capturing product affinities

    Old style

    select d1.InvNum,d1.ItemID,d2.ItemID

    from InvDetl d1,InvDetl d2

    where d1.InvNum=d2.InvNum and d1.ItemID<>d2.ItemID

    New style

    select d1.InvNum,d1.ItemID,d2.ItemID

    from InvDetl d1

      INNER join InvDetl d2 on d1.InvNum=d2.InvNum and d1.ItemID<>d2.ItemID

    or

    select d1.InvNum,d1.ItemID,d2.ItemID

    from InvDetl d1

      CROSS join InvDetl d2

    WHERE d1.InvNum=d2.InvNum and...

Viewing 15 posts - 1,366 through 1,380 (of 1,496 total)