how can i insert in udf

  • i just want to know ,how you select max (date)

    max is not working as date is datetime

  • hbtkp (4/16/2012)


    i just want to know ,how you select max (date)

    max is not working as date is datetime

    Define not working. Did it return the wrong value? Did it return null? did you get a syntax error? Did it reformat your harddrive? Maybe it took your dog for a walk?

    Nobody can see over your shoulder.

    http://msdn.microsoft.com/en-us/library/ms187751.aspx

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • hbtkp (4/16/2012)


    i just want to know ,how you select max (date)

    max is not working as date is datetime

    MAX works just fine on a datetime data type.

    SELECT MAX(<Datetime column>) FROM <whereever>

    Whatever the problem is, it is not that max does not work on datetimes.

    If I had to guess, it's a varchar column not a datetime. Convert to datetime first, then max.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • hbtkp (4/16/2012)


    i just want to know ,how you select max (date)

    max is not working as date is datetime

    Really? Try running this code:

    WITH TestData(dates) AS (

    SELECT

    CAST('20120416 09:12:30.000' AS DATETIME)

    UNION ALL

    SELECT

    CAST('20120416 09:05:30.000' AS DATETIME)

    UNION ALL

    SELECT

    CAST('20120416 09:14:33.000' AS DATETIME)

    UNION ALL

    SELECT

    CAST('20120416 09:06:27.000' AS DATETIME)

    )

    SELECT

    MAX(dates)

    FROM

    TestData;

    It seems to select the max date from the list provided. Since we can't see what you are doing, however, there really is no way to help you unless you take the time to provide us with the information we need to really be able to help you. Can't say this enough obviously, help us help you.

  • OK SORRY MAX date its working.

    help me with cumulative calculation

  • hbtkp (4/16/2012)


    OK SORRY MAX date its working.

    help me with cumulative calculation

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Help us help by posting details.

    Have we said it enough yet????

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • hbtkp (4/16/2012)


    OK SORRY MAX date its working.

    help me with cumulative calculation

    How are we supposed to help? You won't give us anything to work with to help you. You have been told so many times what we need from you that it is starting to sound like a broken record.

    If you want our help, give us what we need to help you. DDL for the table(s), sample data for the table(s), expected results based on the sample data, and the code you have written so far to solve your problem so we can see what you have tried so far.

    Really, we can't see what you are doing at your place of work. We don't have access to your systems to look at the data structures or the data. We can't read your mind either. You have to help us help you.

  • Sean Lange (4/16/2012)


    hbtkp (4/16/2012)


    OK SORRY MAX date its working.

    help me with cumulative calculation

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Help us help you by posting details.

    Have we said it enough yet????

    Nope. I added a few more here.

  • i just need math formula to calculate cumulative field. in sql.

    is there any build in function

  • hbtkp (4/16/2012)


    i just need math formula to calculate cumulative field. in sql.

    is there any build in function

    A + B - C. There, a formula as useful as anything you have provided us.

  • i have this data in 1 table

    I1

    2.3

    4.5

    3.4

    2.3

    1.2

    now i need output lik this

    cumulative of I1

    ----------

    how to do it

  • hbtkp (4/16/2012)


    i have this data in 1 table

    I1

    2.3

    4.5

    3.4

    2.3

    1.2

    now i need output lik this

    cumulative of I1

    ----------

    how to do it

    Absolutely no idea. I see no decernable pattern in the values so you will need to provide the formula that generates the value pairs you provided.

  • NUMBER CUMULATIVE

    0.00

    2.78 2.78

    1.01 3.82

    2.07 5.97

    1.71 7.78

    2.21 10.16

    0.23 10.41

    0.69 11.17

    -0.01 11.16

    -1.70 9.27

    5.51 15.29

    -2.47 12.44

    -4.28 7.63

    2.97 10.82

    -2.50 8.06

    2.38 10.62

    FINAL CUMULATIVE 10.62

  • How about a simple explanation about what you want??? What is a cumulative? Do you have a column with that information in it? I hope your communication skills in real life are better than you can do online.

    From what you posted it looks like maybe you want the value in the cumulative column? Assuming you have another column that you can use to sort by you could use top 1 order by some column. If it is calculated some business rules would go a long way towards an answer.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • i dont know what is cumulative formula.

    but this is how i am getting my final data in report.

    so based on how they calculate , i need to do implement that formula in sql.

    this result is accurate.i need to figure out formula based on that

Viewing 15 posts - 31 through 45 (of 85 total)

You must be logged in to reply to this topic. Login to reply