Forum Replies Created

Viewing 15 posts - 1,891 through 1,905 (of 3,957 total)

  • RE: Group by help

    SQLSACT (3/4/2013)


    Thanks

    Quick question - Why doesn't this work?:

    SELECT name, purchase_date, product, quantity

    ,n = ROW_NUMBER() OVER (PARTITION BY name ORDER BY...

  • RE: Select.. where column1 in (@var)

    Didn't Todd Fifield just write an article on this?

    http://www.sqlservercentral.com/articles/T-SQL/73838/

  • RE: Query Help

    Lynn beat me to it by a minute or two, but here's another way:

    create table #Class

    (code int,

    CName varchar(10))

    create table #Amount

    (code int,

    Currency char(3),

    Amount float)

    insert into #Class

    select 1 , 'ASD' UNION...

  • RE: Group by help

    Not really possible with a GROUP BY because you want two columns off the row with the max date, so use a window function:

    create table #table1

    (name nvarchar(50), purchase_date datetime,product...

  • RE: cursor

    Something like this should get you started:

    CREATE TABLE #MyDates

    (SLN INT, ID INT, StartDate DATETIME, EndDate DATETIME

    ,Duration AS (DATEDIFF(minute, StartDate, EndDate))

    ...

  • RE: How to compare parent child data in SQL

    Jeff Moden (2/27/2013)


    dwain.c (2/27/2013)


    However I think it may be a bit overkill in this case where all you need to do is sum the children of a parent to one...

  • RE: How to compare parent child data in SQL

    A couple of quick points:

    1. Since you're a first time poster, you should understand that to get better, faster and more accurate help you should follow the first link in...

  • RE: The Beer Cooler Thread

    Revenant (2/27/2013)


    Over six months and no post... No one drinking beer any longer?

    I've been too inebriated on beer to post! :w00t::hehe::hehe:

  • RE: change a result into one record

    ChrisM@Work (2/27/2013)


    Jeff, you and Dwain may have missed the preceeding part of this case.

    @dmarz96, it's much easier to see what you are trying to do, now that I've seen both...

  • RE: Are the posted questions getting worse?

    Sean Lange (2/25/2013)


    Another crazy snowstorm in Kansas City. This is the second thunder snow in 5 days. It is really quite odd to hear rolling thunder while it is blizzarding....

  • RE: Need help with a select, insert

    polkadot (2/26/2013)


    ...

    --DDL for Merge/Update statement

    MERGE companyassignments T

    USING

    (SELECT ua.userid, eu.username, ua.companyname

    FROM userassignments ua

    JOIN existingusers eu on

    eu.userid = ua.id

    where companyname in (

    SELECT companyname

    FROM existingcompanies)) as S

    on t.username = s.username

    and t.companyname...

  • RE: change a result into one record

    Jeff Moden (2/26/2013)


    dwain.c (2/26/2013)


    Like this?

    Looks like it. Heh... we make a hell of a tag team. I'll flush out the requiremments, you write the code. 🙂

    Yeah, aren't we...

  • RE: change a result into one record

    Like this?

    WITH PriorResults (HPROP, STYPE, SVALUE, NSFFee, SecDepIntRate)

    AS (

    SELECT 240, 'DDEPOSITINTEREST', 0, NULL, 3000.0000

    UNION ALL SELECT 240, 'NSFFee', 0, 50.0000, NULL

    )

    SELECT...

  • RE: Need help with a select, insert

    wolfkillj (2/26/2013)


    daglugub 60457 (2/25/2013)


    I took the time to create that scenario because I am asking for help so I wanted to be specific as possible. I guess that backfired...

  • RE: Show all data from four tables joined or matched on a particular column

    It can also be done using OUTER APPLY, which could be especially handy if you need to return additional columns from each of the 4 tables.

    ;WITH AllComputers AS (

    ...

Viewing 15 posts - 1,891 through 1,905 (of 3,957 total)