Forum Replies Created

Viewing 15 posts - 151 through 165 (of 283 total)

  • RE: Using an expression in a GROUP BY clause

    Gerry Roston (2/23/2015)


    may well suffice from an application perspective.

    However this seems odd - I need to divide, then multiple by the same constant value. Is there a better...

  • RE: Using an expression in a GROUP BY clause

    Gerry Roston (2/23/2015)


    All,

    SELECT StartTime + Offset, min(Sensor), max(Sensor)

    FROM SensorData

    WHERE SensorID = @SensorID AND

    StartTime + Offset > @BeginTime AND

    StartTime + Offset < @EndTime

    GROUP BY (StartTime +...

  • RE: Queries and Joining tables

    Jeff Moden (2/23/2015)


    Heh... table names as plural nouns. Makes for some interesting and non-automatable naming conventions.

    So, let me ask... do you have an Employee table or an Employees table?...

  • RE: Find most recent record of consecutive dates

    robert.wiglesworth (2/23/2015)


    From this table, I would like a query that would give me this result:

    01/15/2015 07/31/2015 2555 ...

  • RE: TOP N records help

    KGJ-Dev (2/14/2015)


    Hi,

    expected result :

    IDmessage

    1Testing 1, Testing 2, Testing 3

    2Testing 6, Testing 7, Testing 8

    3Testing 11, Testing 12, Testing 13

    any help please

    I just added a TOP 3 to the select...

  • RE: GET 1 RECORD WHERE STARTDATES ARE IDENTICAL

    Lowell (2/10/2015)


    must be missing something in the question...

    Same thought crossed my mind.

    With the given information, I am guessing that the ending date is just a magic date far in...

  • RE: Removing Duplicates

    Sioban Krzywicki (1/23/2015)


    Sure! That's a way you can do it. Want to post some code to share with people? I find multiple ways of doing things is both nice to...

  • RE: SQL While statement

    denis.gendera (1/21/2015)


    Thx for the info, I do have follow-up question

    the 2nd query does acutally use function to return rows and that should also be populated with the info from first...

  • RE: SQL While statement

    denis.gendera (1/21/2015)


    I have table with PatchGroup Information. I like to run query using While statement that returns specific results for each patch group.

    I'm using SQL Function and doing the...

  • RE: Help Needed in Avoiding RBAR

    KGJ-Dev (1/20/2015)


    Below is my try,

    DECLARE @Affected TABLE (UserId INT);

    WITH data

    AS (

    SELECT UserId

    ,ProcessingAmout = SUM(COALESCE(Amount, 0))

    FROM @tblCompanyProess

    WHERE IsProcessed = 0

    )

    UPDATE @UserBalance

    SET UserAmountBalance = COALESCE(B.UserAmountBalance, 0) + D.ProcessingAmout

    OUTPUT INSERTED.IdMember

    INTO @Affected(IDMember)

    FROM @UserBalance UB

    INNER...

  • RE: Join/merge tables

    dmj120 (1/20/2015)


    I am trying to join a few tables, but using the below code I lose many records. The records table has about 27000 rows but after joining the...

  • RE: SQL Select stament

    Here is another even simpler solution!

    declare @t table

    (

    ID int

    , code1 char

    , code2 char

    )

    insert @t values

    (1,'a','m')

    ,(1,'b','n')

    ,(1,'c','T')

    ,(2,'d','m')

    ,(2,'e','n')

    ,(2,'f','n')

    ,(3,'g','m')

    ,(3,'h','n')

    ,(3,'i','T')

    ;with cte as

    (

    Select id

    ...

  • RE: Top 3 sales per salesmanID

    This is a way to get the top 3 unique order amounts for each Salesman_ID. This uses the same data set that I posted previously.

    ;with cte as

    (

    ...

  • RE: Top 3 sales per salesmanID

    sdh96 (12/2/2014)


    That worked great but there are repetative dollar amounts. Can you display how to retrieve the exact same information but three distinct dollar amounts.

    I threw this data together...

Viewing 15 posts - 151 through 165 (of 283 total)