Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible in one SELECT command?
Message
From
31/10/2005 17:30:25
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01063783
Message ID:
01063842
Views:
15
>Fabio
>Why is it you need it? I have an OperationID field which is the primary key for the table, but i don't think it's relevant in this case.
>Here, the user will enter the date for Sunday ( let's call it SunDate ) and i just extract all records where BETWEEN( CDate, SunDate, SunDate+3 ) ordered by CTime.
>Jaime
SELECT ;
	CTime ;
,	MAX(IIF(DateW=1,Patient,SPACE(30)))	AS Sunday     ;
,	MAX(IIF(DateW=2,Patient,SPACE(30)))	AS Monday     ;
,	MAX(IIF(DateW=3,Patient,SPACE(30)))	AS Tuesday    ;
,	MAX(IIF(DateW=4,Patient,SPACE(30)))	AS Wednesday  ;
,	MAX(IIF(DateW=5,Patient,SPACE(30)))	AS Thursday	;
,	MAX(IIF(DateW=6,Patient,SPACE(30)))	AS Friday	;
,	MAX(IIF(DateW=7,Patient,SPACE(30)))	AS Saturday	;
	FROM (SELECT	MAX(T.CTime) 	   CTime   ;
	,		MAX(DOW(T.CDate))  DateW   ;
	,		MAX(T.Patient)	   Patient ;
	,		COUNT(*)           rowInGroup;
			FROM theTable T ;
			LEFT JOIN theTable RN ;
				ON RN.OperationID <= T.OperationID ;
				AND RN.CTime=T.CTime ;
				AND DOW(RN.CDate)=DOW(T.CDate);
			GROUP BY T.OperationID) GG;
	GROUP BY CTime,rowInGroup
if it is slow, a variation exists
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform