Hello,
I have a query that is calculating the age of cattle. Each cow is in a table called stock which lists all of their information. I would like to be able to run a query that displays each cow’s information in addition to their age that was calculated in a different query. My thoughts are either I can use a query to do this or I wish there was a way to store the age calculated in the query in the main table (stock).
This is the code in my query calculating the age (it is called Age).
SELECT "ID", ( 1.0 * "MYDATE" / 365 ) AS "AGE" FROM ( SELECT "ID", DATEDIFF( 'day', "DOB", CURRENT_TIMESTAMP ) "MYDATE" FROM "Stock" )
This is a query I have that lists all of the different cows and their information
SELECT "ID", "Type", "Status", "Name", "Tag #", "Breed/Color" FROM "Stock"
I have attempted several tutorials on subqueries but am not getting the syntax right and keep getting error messages when I try to add the Age query in parenthesis to the second query I showed.
All tips and any help are much appreciated!