Database: works_cycles
Tables: CountryRegion, Culture, Currency, CountryRegionCurrency, Person, BusinessEntityContact, EmailAddress, Employee, Password, PersonCreditCard, ProductCategory, ProductDescription, ProductModel, ProductModelProductDescriptionCulture, ProductPhoto, ProductSubcategory, SalesReason, SalesTerritory, SalesPerson, SalesPersonQuotaHistory, SalesTerritoryHistory, ScrapReason, Shift, ShipMethod, SpecialOffer, BusinessEntityAddress, SalesTaxRate, Store, SalesOrderHeaderSalesReason, TransactionHistoryArchive, UnitMeasure, ProductCostHistory, ProductDocument, ProductInventory, ProductProductPhoto, ProductReview, ShoppingCartItem, SpecialOfferProduct, SalesOrderDetail, TransactionHistory, Vendor, ProductVendor, PurchaseOrderHeader, PurchaseOrderDetail, WorkOrder, WorkOrderRouting, Customer, ProductListPriceHistory, Address, AddressType, BillOfMaterials, BusinessEntity, ContactType, CurrencyRate, Department, EmployeeDepartmentHistory, EmployeePayHistory, JobCandidate, Location, PhoneNumberType, Product, Document, StateProvince, CreditCard, SalesOrderHeader
Columns (table index, column name): -1, *, 0, CountryRegionCode, 0, Name, 0, ModifiedDate, 1, CultureID, 1, Name, 1, ModifiedDate, 2, CurrencyCode, 2, Name, 2, ModifiedDate, 3, CountryRegionCode, 3, CurrencyCode, 3, ModifiedDate, 4, BusinessEntityID, 4, PersonType, 4, NameStyle, 4, Title, 4, FirstName, 4, MiddleName, 4, LastName, 4, Suffix, 4, EmailPromotion, 4, AdditionalContactInfo, 4, Demographics, 4, rowguid, 4, ModifiedDate, 5, BusinessEntityID, 5, PersonID, 5, ContactTypeID, 5, rowguid, 5, ModifiedDate, 6, BusinessEntityID, 6, EmailAddressID, 6, EmailAddress, 6, rowguid, 6, ModifiedDate, 7, BusinessEntityID, 7, NationalIDNumber, 7, LoginID, 7, OrganizationNode, 7, OrganizationLevel, 7, JobTitle, 7, BirthDate, 7, MaritalStatus, 7, Gender, 7, HireDate, 7, SalariedFlag, 7, VacationHours, 7, SickLeaveHours, 7, CurrentFlag, 7, rowguid, 7, ModifiedDate, 8, BusinessEntityID, 8, PasswordHash, 8, PasswordSalt, 8, rowguid, 8, ModifiedDate, 9, BusinessEntityID, 9, CreditCardID, 9, ModifiedDate, 10, ProductCategoryID, 10, Name, 10, rowguid, 10, ModifiedDate, 11, ProductDescriptionID, 11, Description, 11, rowguid, 11, ModifiedDate, 12, ProductModelID, 12, Name, 12, CatalogDescription, 12, Instructions, 12, rowguid, 12, ModifiedDate, 13, ProductModelID, 13, ProductDescriptionID, 13, CultureID, 13, ModifiedDate, 14, ProductPhotoID, 14, ThumbNailPhoto, 14, ThumbnailPhotoFileName, 14, LargePhoto, 14, LargePhotoFileName, 14, ModifiedDate, 15, ProductSubcategoryID, 15, ProductCategoryID, 15, Name, 15, rowguid, 15, ModifiedDate, 16, SalesReasonID, 16, Name, 16, ReasonType, 16, ModifiedDate, 17, TerritoryID, 17, Name, 17, CountryRegionCode, 17, Group, 17, SalesYTD, 17, SalesLastYear, 17, CostYTD, 17, CostLastYear, 17, rowguid, 17, ModifiedDate, 18, BusinessEntityID, 18, TerritoryID, 18, SalesQuota, 18, Bonus, 18, CommissionPct, 18, SalesYTD, 18, SalesLastYear, 18, rowguid, 18, ModifiedDate, 19, BusinessEntityID, 19, QuotaDate, 19, SalesQuota, 19, rowguid, 19, ModifiedDate, 20, BusinessEntityID, 20, TerritoryID, 20, StartDate, 20, EndDate, 20, rowguid, 20, ModifiedDate, 21, ScrapReasonID, 21, Name, 21, ModifiedDate, 22, ShiftID, 22, Name, 22, StartTime, 22, EndTime, 22, ModifiedDate, 23, ShipMethodID, 23, Name, 23, ShipBase, 23, ShipRate, 23, rowguid, 23, ModifiedDate, 24, SpecialOfferID, 24, Description, 24, DiscountPct, 24, Type, 24, Category, 24, StartDate, 24, EndDate, 24, MinQty, 24, MaxQty, 24, rowguid, 24, ModifiedDate, 25, BusinessEntityID, 25, AddressID, 25, AddressTypeID, 25, rowguid, 25, ModifiedDate, 26, SalesTaxRateID, 26, StateProvinceID, 26, TaxType, 26, TaxRate, 26, Name, 26, rowguid, 26, ModifiedDate, 27, BusinessEntityID, 27, Name, 27, SalesPersonID, 27, Demographics, 27, rowguid, 27, ModifiedDate, 28, SalesOrderID, 28, SalesReasonID, 28, ModifiedDate, 29, TransactionID, 29, ProductID, 29, ReferenceOrderID, 29, ReferenceOrderLineID, 29, TransactionDate, 29, TransactionType, 29, Quantity, 29, ActualCost, 29, ModifiedDate, 30, UnitMeasureCode, 30, Name, 30, ModifiedDate, 31, ProductID, 31, StartDate, 31, EndDate, 31, StandardCost, 31, ModifiedDate, 32, ProductID, 32, DocumentNode, 32, ModifiedDate, 33, ProductID, 33, LocationID, 33, Shelf, 33, Bin, 33, Quantity, 33, rowguid, 33, ModifiedDate, 34, ProductID, 34, ProductPhotoID, 34, Primary, 34, ModifiedDate, 35, ProductReviewID, 35, ProductID, 35, ReviewerName, 35, ReviewDate, 35, EmailAddress, 35, Rating, 35, Comments, 35, ModifiedDate, 36, ShoppingCartItemID, 36, ShoppingCartID, 36, Quantity, 36, ProductID, 36, DateCreated, 36, ModifiedDate, 37, SpecialOfferID, 37, ProductID, 37, rowguid, 37, ModifiedDate, 38, SalesOrderID, 38, SalesOrderDetailID, 38, CarrierTrackingNumber, 38, OrderQty, 38, ProductID, 38, SpecialOfferID, 38, UnitPrice, 38, UnitPriceDiscount, 38, LineTotal, 38, rowguid, 38, ModifiedDate, 39, TransactionID, 39, ProductID, 39, ReferenceOrderID, 39, ReferenceOrderLineID, 39, TransactionDate, 39, TransactionType, 39, Quantity, 39, ActualCost, 39, ModifiedDate, 40, BusinessEntityID, 40, AccountNumber, 40, Name, 40, CreditRating, 40, PreferredVendorStatus, 40, ActiveFlag, 40, PurchasingWebServiceURL, 40, ModifiedDate, 41, ProductID, 41, BusinessEntityID, 41, AverageLeadTime, 41, StandardPrice, 41, LastReceiptCost, 41, LastReceiptDate, 41, MinOrderQty, 41, MaxOrderQty, 41, OnOrderQty, 41, UnitMeasureCode, 41, ModifiedDate, 42, PurchaseOrderID, 42, RevisionNumber, 42, Status, 42, EmployeeID, 42, VendorID, 42, ShipMethodID, 42, OrderDate, 42, ShipDate, 42, SubTotal, 42, TaxAmt, 42, Freight, 42, TotalDue, 42, ModifiedDate, 43, PurchaseOrderID, 43, PurchaseOrderDetailID, 43, DueDate, 43, OrderQty, 43, ProductID, 43, UnitPrice, 43, LineTotal, 43, ReceivedQty, 43, RejectedQty, 43, StockedQty, 43, ModifiedDate, 44, WorkOrderID, 44, ProductID, 44, OrderQty, 44, StockedQty, 44, ScrappedQty, 44, StartDate, 44, EndDate, 44, DueDate, 44, ScrapReasonID, 44, ModifiedDate, 45, WorkOrderID, 45, ProductID, 45, OperationSequence, 45, LocationID, 45, ScheduledStartDate, 45, ScheduledEndDate, 45, ActualStartDate, 45, ActualEndDate, 45, ActualResourceHrs, 45, PlannedCost, 45, ActualCost, 45, ModifiedDate, 46, CustomerID, 46, PersonID, 46, StoreID, 46, TerritoryID, 46, AccountNumber, 46, rowguid, 46, ModifiedDate, 47, ProductID, 47, StartDate, 47, EndDate, 47, ListPrice, 47, ModifiedDate, 48, AddressID, 48, AddressLine1, 48, AddressLine2, 48, City, 48, StateProvinceID, 48, PostalCode, 48, SpatialLocation, 48, rowguid, 48, ModifiedDate, 49, AddressTypeID, 49, Name, 49, rowguid, 49, ModifiedDate, 50, BillOfMaterialsID, 50, ProductAssemblyID, 50, ComponentID, 50, StartDate, 50, EndDate, 50, UnitMeasureCode, 50, BOMLevel, 50, PerAssemblyQty, 50, ModifiedDate, 51, BusinessEntityID, 51, rowguid, 51, ModifiedDate, 52, ContactTypeID, 52, Name, 52, ModifiedDate, 53, CurrencyRateID, 53, CurrencyRateDate, 53, FromCurrencyCode, 53, ToCurrencyCode, 53, AverageRate, 53, EndOfDayRate, 53, ModifiedDate, 54, DepartmentID, 54, Name, 54, GroupName, 54, ModifiedDate, 55, BusinessEntityID, 55, DepartmentID, 55, ShiftID, 55, StartDate, 55, EndDate, 55, ModifiedDate, 56, BusinessEntityID, 56, RateChangeDate, 56, Rate, 56, PayFrequency, 56, ModifiedDate, 57, JobCandidateID, 57, BusinessEntityID, 57, Resume, 57, ModifiedDate, 58, LocationID, 58, Name, 58, CostRate, 58, Availability, 58, ModifiedDate, 59, PhoneNumberTypeID, 59, Name, 59, ModifiedDate, 60, ProductID, 60, Name, 60, ProductNumber, 60, MakeFlag, 60, FinishedGoodsFlag, 60, Color, 60, SafetyStockLevel, 60, ReorderPoint, 60, StandardCost, 60, ListPrice, 60, Size, 60, SizeUnitMeasureCode, 60, WeightUnitMeasureCode, 60, Weight, 60, DaysToManufacture, 60, ProductLine, 60, Class, 60, Style, 60, ProductSubcategoryID, 60, ProductModelID, 60, SellStartDate, 60, SellEndDate, 60, DiscontinuedDate, 60, rowguid, 60, ModifiedDate, 61, DocumentNode, 61, DocumentLevel, 61, Title, 61, Owner, 61, FolderFlag, 61, FileName, 61, FileExtension, 61, Revision, 61, ChangeNumber, 61, Status, 61, DocumentSummary, 61, Document, 61, rowguid, 61, ModifiedDate, 62, StateProvinceID, 62, StateProvinceCode, 62, CountryRegionCode, 62, IsOnlyStateProvinceFlag, 62, Name, 62, TerritoryID, 62, rowguid, 62, ModifiedDate, 63, CreditCardID, 63, CardType, 63, CardNumber, 63, ExpMonth, 63, ExpYear, 63, ModifiedDate, 64, SalesOrderID, 64, RevisionNumber, 64, OrderDate, 64, DueDate, 64, ShipDate, 64, Status, 64, OnlineOrderFlag, 64, SalesOrderNumber, 64, PurchaseOrderNumber, 64, AccountNumber, 64, CustomerID, 64, SalesPersonID, 64, TerritoryID, 64, BillToAddressID, 64, ShipToAddressID, 64, ShipMethodID, 64, CreditCardID, 64, CreditCardApprovalCode, 64, CurrencyRateID, 64, SubTotal, 64, TaxAmt, 64, Freight, 64, TotalDue, 64, Comment, 64, rowguid, 64, ModifiedDate
Question: Calculate the average age of employee in each department and state which department has the youngest employees.
Evidence: Average = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID) by each Department ID; youngest employee refers to Min(BirthDate);
SQL: SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY T1.BirthDate DESC LIMIT 1