Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by jdaman

  1. jdaman

    Getting "Distinct" of first field only

    You could use the following solution: SELECT tiMNMmbrno, ttMNMnincr, tvMNMntype, tvMNMrelat, tvMMBclass, tsMMBmyear, tvMMBmpref, tcMNMfirst, tcMNMmidle, tcMNMlastn, tvMNMgnrtn, tcMADline1...
  2. jdaman

    Finding a Delimiter in SQL

    This should do what youre looking for: DECLARE @a TABLE ( col1 VARCHAR(25) ) INSERT @a ( col1 ) SELECT NULL UNION SELECT 'GL' UNION SELECT 'GL/PRIMARY' UNION SELECT 'GL/PRIMARY/OCCURANCE' SELECT col1, CASE WHEN CHARINDEX('/', col1) = 0 THEN col1...
  3. jdaman

    Convert to Month Name and Year

    SELECT pp.PatientId, dbo.FormatName(pp.Prefix, pp.[First], pp.Middle, pp.[Last], pp.Suffix) AS PatName, pv.Visit, MonthNumber=convert(varchar(2),datepart(month,pv.visit)), (Select DateName(Month, pv.visit)) AS VisitMonth, (SELECT Convert(VarChar(4), Year(pv.visit))) AS...
  4. jdaman

    Decimal calculation problem

    Yes, you are correct. It is dependent on a static set of values in the source column otherwise it will fail. I keep thinking there must be a more elegant way to provide the data that doesnt involve looping or throwing my suggestion into a dynamic script (which at that point would be even more...
  5. jdaman

    Decimal calculation problem

    forgot to post the result set: PRODUCTID PRICEDATE BASE_PRICE A_PRICE_INCREASE B_PRICE_INCREASE C_PRICE_INCREASE D_PRICE_INCREASE ----------- -----------------------...
  6. jdaman

    Decimal calculation problem

    I thought there had to be an easier way. I just didn't think it would kill me..." Qik3Coder, It really seems like it should be easier but, as my code attests to, I didnt find that easy solution. I do see where I have a problem displaying multiple different prices for a product in my code...
  7. jdaman

    Decimal calculation problem

    Sorry for the late reply... If you have a static number of sources the following (untested) code should work: DECLARE @a TABLE( PRODUCTID INT, PRICEDATE DATETIME, PRICE DECIMAL(8,2), SOURCE CHAR(1) ) INSERT @a ( PRODUCTID, PRICEDATE, PRICE, SOURCE ) SELECT 1, '20080102', 10.12, 'A' UNION...
  8. jdaman

    Decimal calculation problem

    What if the price listed for A, B, and C are all different?
  9. jdaman

    Trim all data in a table

    There is no need to loop anything. update <your table> set <column1> = ltrim(rtrim(<column1>)), <column2> = ltrim(rtrim(<column2>)), ... <column68> = ltrim(rtrim(<column68>)) However, I would think you would better off validating the data when created rather than scrubbing it after...
  10. jdaman

    CASE Statement Help

    Running your [400.PatientAge] in your derived table through a case statement similar to this would pass a numeric value to your case statement in your select statement: declare @a table ( age varchar(10) ) insert @a ( age ) select '1 yr' union all select '3 mo' union all select '10 wks' select...
  11. jdaman

    CASE Statement Help

    I would suggest storing the information in a numeric data type. Example: 1yr = 1 2mo = (2*30)/365 8wks = (8*7)/365
  12. jdaman

    CASE Statement Help

    Since you are doing numeric comparisons in your case statement against [400.PatientAge] I would assume that you have non-numeric values stored in that column.

Part and Inventory Search

Back
Top