Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL and COUNT?
Message
From
26/10/2005 13:17:39
 
 
To
26/10/2005 12:55:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01062221
Message ID:
01062297
Views:
13
You're right. I missed that
SELECT c.jobno,a.drwno,c.lastrev,a.revno,b.date AS trdate,a.transno ;
FROM issuehistory a ;
	LEFT JOIN transmittallog b ;
		ON a.transno = b.transno ;
	LEFT JOIN drawinglog c ;	
		ON ALLTRIM(a.drwno)==ALLTRIM(c.drwno) ;
INTO CURSOR curPrint_1 NoFilter ;
WHERE !DELETED() AND (ALLTRIM(b.iscode)=='A' OR ALLTRIM(b.iscode)=='B') ;
ORDER BY c.jobno,sort1,sort2,sort3

select *, ;
       recno() as rec_1 ;
   from curPrint_1 ;
   into cursor curprint_2

select jobno, ;
       drwno, ;
       min(rec_1) as rec_2 ;
    from curprint_2 ;
    into curprint_3 ;
    group by 1, 2

select curPrint_1.*, ;
       (rec_1 = rec_2) as First ;
    from  curprint_2, curprint_3 ;
    into cursor curprint ;
    where ( curprint_2.jobno == curprint_3.jobno ) ;
     and  ( curprint_2.drwno == curprint_3.drwno)




>I think it doesn't helps. Chek to see that Russel wants two .T. values in his example.
>
>
>>Russel,
>>
>>Think you'll need two queries
>>
>>
>>SELECT c.jobno,a.drwno,c.lastrev,a.revno,b.date AS trdate,a.transno ;
>>FROM issuehistory a ;
>>	LEFT JOIN transmittallog b ;
>>		ON a.transno = b.transno ;
>>	LEFT JOIN drawinglog c ;	
>>		ON ALLTRIM(a.drwno)==ALLTRIM(c.drwno) ;
>>INTO CURSOR curPrint_1 NoFilter ;
>>WHERE !DELETED() AND (ALLTRIM(b.iscode)=='A' OR ALLTRIM(b.iscode)=='B') ;
>>ORDER BY c.jobno,sort1,sort2,sort3
>>
>>
>>select *, ;
>>       (recno()=1) as First ;
>>    from curPrint_1 ;
>>    into cursor curPrint
>>
>>
>>
>>>I have the following SQL statement:
>>>
>>>
>>>SELECT c.jobno,a.drwno,c.lastrev,a.revno,b.date AS trdate,a.transno ;
>>>FROM issuehistory a ;
>>>	LEFT JOIN transmittallog b ;
>>>		ON a.transno = b.transno ;
>>>	LEFT JOIN drawinglog c ;	
>>>		ON ALLTRIM(a.drwno)==ALLTRIM(c.drwno) ;
>>>INTO CURSOR curPrint ;
>>>WHERE !DELETED() AND (ALLTRIM(b.iscode)=='A' OR ALLTRIM(b.iscode)=='B') ;
>>>ORDER BY c.jobno,sort1,sort2,sort3
>>>
>>>
>>
>>>
>>>This returns the following:
>>>
>>>
>>>Jobno      Drwno     Lastrev     Revno    Trdate     Transno
>>>6037       E101A        C         0     01/17/2003    58995
>>>6037       E101A        C         0     01/24/2003    59159
>>>6037       E101A        C         A     02/10/2003    59352
>>>6037         1          B         0     01/17/2003    58995
>>>6037         1          B         A     01/24/2003    59159
>>>...
>>>
>>>
>>>Is there a way to tag the first instance of a drawing number? Something like below:
>>>
>>>
>>>Jobno      Drwno     Lastrev     Revno    Trdate     Transno   First
>>>6037       E101A        C         0     01/17/2003    58995      .T.
>>>6037       E101A        C         0     01/24/2003    59159      .F.
>>>6037       E101A        C         A     02/10/2003    59352      .F.
>>>6037         1          B         0     01/17/2003    58995      .T.
>>>6037         1          B         A     01/24/2003    59159      .F.
>>>...
>>>
>>>
>>>Any help would be greatly appreciated.
>>>
>>>Thanks in advance.
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform