Forum Replies Created

Viewing 15 posts - 856 through 870 (of 2,452 total)

  • RE: TSQL Dynamic columns and SUM at the end

    hexdecimal1989 (3/20/2016)


    For some reason, when I Post a reply, it gone away.

    Please find this dropbox link:

    Thanks!

    your dropbox script doesnt contain Employee table....which I beleive is required

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Order When Exists

    rootfixxxer (3/19/2016)


    Just add another athlete to the temp table:

    UNION ALL

    SELECT 1,3,'P1',3

    UNION ALL

    SELECT 1,3,'P2',4

    UNION ALL

    SELECT 1,3,'END',7

    UNION ALL

    SELECT 2,3,'P1',1

    UNION ALL

    SELECT 2,3,'P2',3

    UNION ALL

    SELECT 2,3,'END',9

    Then using your code, with the order by

    SELECT ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Order When Exists

    rootfixxxer (3/19/2016)


    Thanks

    But that doesn't work weel, because the rows must be order by time sofar, and the number 2 will have less time because it haven't completed the second stage...

    so...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Order When Exists

    try this for starters

    SELECT Num, MAX(CASE WHEN stage = 1 THEN timespent ELSE 0 END) AS s1,

    ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Order When Exists

    rootfixxxer (3/19/2016)


    No, the values were made up... sorry

    With the test data, after stage 2, with a total of 4 stages, should be:

    1 | 10 | 15 | - | -...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Order When Exists

    Sample:

    Athlete | Stage 1 | Stage 2 | ... | Total

    Name1 | 10 | 7 | .... | 17

    Name2 | 07 | DNF | ... |7

    for clarification....is the above...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: t-sql 2012 sort order

    sample data and expected results would help please.

    students under 6 on 1st jan could be something like this

    select yadda, yadda from whatever where yourdate <= dateadd(yy, datediff(yy, 0,...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: t-sql 2012 sort order

    have you got the TSQL for your age calculations.....or is this part of your question?

    some sample create table/insert data scripts and expected results will probably help

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: SQL code to check IFEXISTS in db

    .....me thinks you maybe comparing a "date" with a "datetime"....(what datatype is "clockin"?) :::: edit...see Ed has already mentioned this

    maybe

    IF (SELECT COUNT(*) FROM dbo.Clock WHERE convert(date,ClockIn) = convert(date,getdate()) AND...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Find difference between two records

    just came across this....seems quite similar, but states MySQL

    http://stackoverflow.com/questions/35917478/find-difference-between-two-records-in-mysql

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Multiple Entris in Night Shift in SQL

    hardik-1087613 (3/12/2016)


    Thanks for your reply.

    Sorry i forgot to mention that i need to set Date wise In-Out Details. As per attachment. Also i added some entries in your given code....

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Avoid Blank Values in a column

    SQL!$@w$0ME (3/12/2016)


    Thanks a lot Alan! Will the update also fails if an empty string is passed?

    suggest you try it 🙂

    UPDATE #yourtable

    SET c4 = ''

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Multiple Entris in Night Shift in SQL

    well I am going to guess that it really isnt as simple as your sample data.......but as a start to the discussion, see below

    USE tempdb

    GO

    --DROP TABLE yourtable;

    CREATE TABLE yourtable(

    ...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Find difference between two records

    ok....please read

    http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/

    then post back with create table statements, sample data and expected results as shown above.

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • RE: Find difference between two records

    looking at your table definition, it would seem that you are not using MS SQL...(.MySQL maybe?)

    this site is for Microsoft SQL predominately ....you may find you get better answers in...

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

Viewing 15 posts - 856 through 870 (of 2,452 total)