Multiple MIN Dates outputs

Viewed 39
Select
                        MIN(Trunc(efc.DATESTAMP)) as MIN_INSTANCE,
                        efc.FIELD_NUMERIC_OLD


                         From EVENT_FIELD_CHANGES efc
                         join SCE.EVENTS_LIST el on El.EVENT_SEQ = EFC.EVENT_SEQ
                         where efc.DESCRIPTION = 'Number of Units Change'
                            and el.JOB_REFERENCE = 'NAM5344483'
                        group by el.JOB_REFERENCE

I am looking to simply look at the oldest field_Numeric_old.

output is showing:

|MIN_INSTANCE | FIELD_NUMERIC_OLD|
date1              230`

date2              200
1 Answers

You are grouping by a field that you are not using in your SELECT. It actually should show an error.

If you are working with SQL Server

Try this instead:

 DECLARE @Limit int
SET @Limit = 1

 SELECT TOP (@Limit)  MIN(Trunc(efc.DATESTAMP)) as MIN_INSTANCE,
                    efc.FIELD_NUMERIC_OLD


                 From EVENT_FIELD_CHANGES efc
                 join SCE.EVENTS_LIST el on El.EVENT_SEQ = EFC.EVENT_SEQ
                 where efc.DESCRIPTION = 'Number of Units Change'
                    and el.JOB_REFERENCE = 'NAM5344483'
                group by efc.FIELD_NUMERIC_OLD`
Related