Forum Replies Created

Viewing 15 posts - 76 through 90 (of 283 total)

  • RE: Update value in table if value exists more than specified

    Raxter (2/10/2016)


    Original data

    AppID Breed age

    101 Pitbull 2

    102 Boxer 4

    103 Pitbull 1

    104 Pitbull 5

    105 Boxer 2

    106 Pitbull 2

    107 Boxer 8

    108 Pitbull 1

    109 Pitbull 3

    110 Boxer 8

    Expected output

    AppID Breed age

    101 Pitbull 2

    102 Boxer 4

    103 Pitbull 1

    104 Pitbull 5

    105 Boxer 2

    106 Pitbull 2

    107 Boxer 8

    108 Pitbull 1

    109 Boxer 3

    110 Boxer 8

    This raises more questions.

    Your example has 2 breeds. What happens when there are more?

    How do you relate Pitbulls to Boxers? Or any...

  • RE: Update value in table if value exists more than specified

    For example, 'pitbull' is in the table 6 times and 'boxer' is in the table 4 times. They both need to be listed in the database 5 times each based...

  • RE: Update value in table if value exists more than specified

    I am posting this as A solution, not as THE solution. I am hoping to learn from a critique of the answer as much as you are!

    Deleting is easy. The...

  • RE: Need to sum up a team's win totals in last 5 games

    archyya (2/1/2016)


    CREATE TABLE [dbo].[teamLogs]

    etc . . .

    WinsLast5games would be an aliased field that would be in this lineup:

    team W L Ov Un WinsLast5games

    STL 11 5 6...

  • RE: Need to sum up a team's win totals in last 5 games

    This is untested air code. But, it should be close enough to get you pointed in a direction that should work.

    ;with cte as

    (

    Select team, ats, atsloss, O,...

  • RE: RECREATE AN ID OF A ROW AFTER BEING DELETED

    abdellahmoh2016 (1/22/2016)


    Hi Thank you for your reply

    It's because my boss suggested me simple like that

    Quite frankly, your boss does not know what he/she is talking about. Reuse of ID's like...

  • RE: Bulk Insert a SQL Statement?

    imba (1/14/2016)


    I have a data output that looks like this:

    SELECT A+|+B+|+C

    Output is A|B|C similar to a text file.

    Is there anyway that I can insert A, B, C into a table...

  • RE: Bulk Insert a SQL Statement?

    imba (1/14/2016)


    I have a data output that looks like this:

    SELECT A+|+B+|+C

    Output is A|B|C similar to a text file.

    Is there anyway that I can insert A, B, C into a table...

  • RE: LEFT JOIN

    Welsh Corgi (1/14/2016)


    I need to create a new table that has an Identity Column so that I can delete the duplicates.

    Setting aside the fact that you don't need an Identity...

  • RE: Datediff between rows with unsequential ID

    John Mitchell-245523 (1/11/2016)


    Is it not as simple as this?

    I don't know. The specs keep changing.

  • RE: Datediff between rows with unsequential ID

    What the heck. Here are two solutions! The first is a 2012 or better, the other for 2008. Of course, using lead provides much better performance in this case....

  • RE: Datediff between rows with unsequential ID

    I'm pretty sure I have a solution. You need to provide a little more information. I need to know which start_date and which end_date you are using in the datediff...

  • RE: Datediff between rows with unsequential ID

    karine.gambarjan (1/8/2016)


    This returns DATEDIFF from the startdate and end_date of the same row where End_date is not null, while I need to calculate a DATEDIFF between 2011-02-01 (end_date row 2)...

  • RE: Date Conversion

    This is a naive way of doing it, but it works.

    declare @iDate int = 01092015

    select cast(substring(cast(@iDate+100000000 as char(11)), 6, 4) + substring(cast(@iDate+100000000 as char(11)), 2, 4) as date)

  • RE: Datediff between rows with unsequential ID

    Here is a slightly less complicated version that gives you the difference in days: (Note the setup of table and data!)

    declare @t table

    (

    id int,

    product...

Viewing 15 posts - 76 through 90 (of 283 total)