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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. mikesoper

    SQL Count Matches

    Hi there, I am comfortable with basic join queries, and sums, but I have not used them in combination before
  2. mikesoper

    SQL Count Matches

    Hi all, I have 2 tables: Stats_table & output_table In stats table there are 10k records, with a unique ID (inst_ID). In output table there will be several thousand records of customers, and each customer also has an inst_ID assigned. What I need to do is for every unique inst_ID in the...
  3. mikesoper

    Javascript - Sum mulitple form option values

    Thanks both of you. I cant beleive I didnt try that - so simple!! Sometimes the easiest answers are the hardest to find (in my case anyway!)
  4. mikesoper

    Javascript - Sum mulitple form option values

    Hi, Each select can only have 1 option selected. Thanks
  5. mikesoper

    Javascript - Sum mulitple form option values

    Hi there, I need a way to sum all selected <option> values from within a form. My form could have up to 100 <selects> all with a name of "Frequencynnnn" nnnn being an ID number. I have tried to modify this script I found: function getFields() { var inputs =...
  6. mikesoper

    Help with SQL query

    Wow that looks intense! I will try first thing on Monday and let you know! Have a great weekend
  7. mikesoper

    Help with SQL query

    Thank you - it says Row_Number is not a recognised function name.... Honestly you have been incredibly helpful, please dont feel you have to continue looking at this as you have given me so much to work from already
  8. mikesoper

    Help with SQL query

    OK I will try and do that. I am not an expert in this area, so this is probably the most complex query I have been asked to do - all your help has been much appreciated.
  9. mikesoper

    Help with SQL query

    Thank you for your support. I get the 3 and 6 month average, but LastMonth is always null? Thanks
  10. mikesoper

    Help with SQL query

    Only thing I dont think its doing is when working out the average it should not take the latest month, so if I have Jan,Feb,Mar,April then 3 month avg should be jan,feb,mar/3 so that I can compare this average with the latest month
  11. mikesoper

    Help with SQL query

    I have this as posted by you yesterday, which works great thanks - I just need to try and add these additional bits on as mentionned above SELECT Prod_Code, Brick_Code, AVG(cast('0' + Number AS Int)) SalesAvg FROM dbo.RAW_SALES_RSA31307 WHERE cast(RIGHT(Month_Code, 2) + '/01/' +...
  12. mikesoper

    Help with SQL query

    Any further suggestions guys? I forgot to say in the post above, that yes indeed there was bad data in the date column! I really need to try and end up with this view: Product - Brick_code - 3MonthAvg - 6MonthAvg - LatestMonth Thanks :)
  13. mikesoper

    Help with SQL query

    Hey guys - we are getting there! I changed to AVG(CAST(NUMBER AS Int)) since this is not money values we are talking about, its quantity. Can I just check - is it taking the last 3 months, but not including the latest month, to calculate the average? Could I also add in a 6 month average, but...
  14. mikesoper

    Help with SQL query

    I get a timeout - there are several hundred thousand rows in this table!
  15. mikesoper

    Help with SQL query

    Doh! Still get I get "syntax error converting datetime from character string" :(
  16. mikesoper

    Help with SQL query

    I am having all sorts of errors! I have pasted the query below - could you check the syntax for me: SELECT Prod_Code, Brick_Code, AVG(cast('0' + Number AS Money)) SalesAvg FROM dbo.RAW_SALES_RSA31307 WHERE cast(RIGHT([Month_Code], 2) + '/01/' + LEFT([Month_Code], 4) AS datetime...
  17. mikesoper

    Help with SQL query

    I get "syntax error converting datetime from character string" Also the sales is a sales quantity rather than money value, so I guess I still want numeric?
  18. mikesoper

    Help with SQL query

    This looks good. However all columns are varchar data type - can I convert the month to datetime and sales to numeric at the same time? Appreciate your help
  19. mikesoper

    Help with SQL query

    Hi - thanks for the reply What I mean is there will be 12 months data - a row for each month and each product and each postcode. So if there 12 rows, each a different month, I need to take the last 3 months/rows but dont include the latest month What I am actually doing here is I will take...

Part and Inventory Search

Back
Top