-2

I need to find all children from my data base who died between birth to 3 months of age within the last one year, in this regard I tried to

Select * 
from deathstable 
where dateofbirth between (curdate() - 274), (curdate() - 183) 

my deathstable contains name, dateoffdeath and cause.

but there seems to be some error in this. Please le me know if there is any better way of doing this.

5
  • I don't see where dateofdeath is used in your query.
    – choroba
    Aug 5, 2018 at 17:48
  • deathstable has the dateofdeath inside it Aug 5, 2018 at 17:50
  • sure, but you don't mention it in the query. But to die before 3 months of age, your dateofdeath must be closer to your dateofbirth than 3 months, right? How is curdate relevant at all?
    – choroba
    Aug 5, 2018 at 17:59
  • @choroba I have edited my question to make it clearer. I need deaths of all toddlers less than 3 months within the past year that is why I am using curdate() Aug 5, 2018 at 18:02
  • 1
    but there seems to be some error in this Yes, a SQL Syntax error. Read the Manual.... any SQL manual and correct the syntax error
    – RiggsFolly
    Aug 5, 2018 at 19:04

1 Answer 1

1

I was thinking it might be better to actually subtract dateofbirth from dateofdisposal so that age always remains 3 months. I have not edited the previous answer incase that one suits you better. something like:

(datediff (dateofdeath, dateofbirth) < 91))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.