( SELECT tt.UpdateByApp1Date AS UpdateDate ( SELECT MAX(UpdateDate) AS LastUpdateDate SELECT ID, UpdateByApp3Date AS UpdateDate SELECT ID, UpdateByApp2Date AS UpdateDate SELECT ID, UpdateByApp1Date AS UpdateDate UNPIVOT ( UpdateDate FOR DateVal IN ( UpdateByApp1Date, UpdateByApp2Date, UpdateByApp3Date ) ) AS u SELECT ID, MAX(UpdateDate) AS LastUpdateDate Here is code toīuild the table and add some sample data.įROM (VALUES (UpdateByApp1Date),(UpdateByApp2Date),(UpdateByApp3Date)) AS UpdateDate(LastUpdateDate)) UpdateByApp1Date, UpdateByApp2Date, UpdateByApp3Date. Update data for each application is stored correspondingly in columns Data in this table is updated from three applications and the
Let's assume that we have a sample table with five columns and three of them haveĪ DATETIME data type. SQL Server allows us to solve this task in different waysĪnd in this tip we will illustrate these solutions and compare performance. Want to choose the maximum date from UpdateByApp1Date, UpdateByApp2Date, UpdateByApp3Date as We want to retrieve data from the table and load it into another table, but we For example we have a table and three of itsĬolumns are of DATETIME type: UpdateByApp1Date, UpdateByApp2Date, Sometimes it's necessary to find the maximum or minimum value from different columns
Max msp 5 highest values from a list how to#
Let us show you how to save time on tedious but critical database documentation tasks. Learn tips and tricks on how to master your data environment with SolarWinds® DataOps solutions, which are designed to help you streamline essential database tasks, database projects, and data-centric application development. Free MSSQLTips Webinar: Master Your Data Environment With DataOps