CT Registry1 Town1 DateFrom1 DateTo1 CT Registry1 Town2 - - && We don't have Filing Dates for this town this week CT Registry1 Town2 DateFrom1' DateTo1' && Could be different, than for town1 etc.Now, I need to give the info about how many Filing Dates we have per registry per week. It means, I need to find Max DateTo and Min DateFrom per each registry per week and calculate number of dates between them excluding Holidays and WeekEnds.
>SELECT * ; > FROM FilingDate ; > WHERE NOT EMPTY (CalMnth) ; > INTO CURSOR TempFDate > >SELECT TempFDate.* ; > from FilingDate ; >UNION > SELECT FilingDate.* > INNER JOIN TempFDate ON FilingDate.AKExceptDate = TempFDate.AKExceptDate ; > WHERE FilingDate.Date < TempFDate.CalMnth ; > HAVING MAX (FilingDate.Date) ><pre> > > >>Hi Cecil, >> >>Thanks a lot. So, first select ordered by rcode, town, calmnth descending gives me all not empty months. Now the task is to select 2 first records per each town... >> >>>Nadya, >>> >>>Try Select * from table where !empty(table.calmnth) gives you all that have a date... >>>Try select distinct <townfield>,<fieldlist> from table where Max(table.calmnth) gives you all the maxdate for each <townfield> >>>hope this helps >>>Cecil >>> >>>>Hi everybody, >>>> >>>>I'm trying to figure out a select statement, if it could be done through SQL. >>>> >>>>I have FilingDate table. It has this structure: >>>><pre> >>>> >>>>Structure for table: G:\REDP\DBC\SUPPORT\FILINGDATE.DBF >>>>Number of data records: 9669 >>>>Date of last update: 01/11/2002 >>>>Memo file block size: 1 >>>> Code Page: 1252 >>>> Field Field Name Type Width >>>> 1 DSID Integer 4 >>>> 2 EXTRYEAR Character 4 >>>> 3 EXTRWEEK Character 2 >>>> 4 STATE Character 2 >>>> 5 CCODE Character 2 >>>> 6 RCODE Character 2 >>>> 7 TOWN Character 4 >>>> 8 RECORD_FM Date 8 >>>> 9 RECORD_TO Date 8 >>>> 10 LANDCT_FM Date 8 >>>> 11 LANDCT_TO Date 8 >>>> 12 CALMNTH Character 10 >>>> 13 MDFLAG Logical 1 >>>> 14 NODATA Logical 1 >>>> 15 NOTES Memo 4 >>>> 16 DDFLAG Logical 1 >>>>** Total ** 70 >>>>>>>>