Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL
Message
From
13/11/2008 07:10:48
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01361585
Message ID:
01361589
Views:
23
Thanks, Sergey. Yes, I'd just figured that and tried it after posting, as Agnes stated too. In that order I get "variable Jobheads not found".

Oops, belay that. I'd forgotten to take the AND clause with the WITH. I'm just checking my results now.


>The JOINs are a part of FROM clause. The WHERE clause goes after that.
>In general, you should always try to keep a query clauses in the order provided in the help file. MS SQL Server, for example is very picky about that. Also it makes your query easier to read.
>
>
>Select	JobAct.OurInvID,  JobHeads.JobID, JobHeads.LabourID, ;
> 		SUM( jobheads.Quantity) as Booked, SUM( jobact.hours) as Charged,  ;
> 		Labour.Text ;
>  from jobheads ;
>  INNER JOIN JobAct ;
>  	ON  jobheads.JobID = jobact.JobID ;
>  INNER JOIN Labour ;
>    ON  Jobheads.LabourID = Labour.ID ;
>  Where jobheads.JobID = "RTvo" ;
>  and not EMPTY( JobAct.OurInvID) ;
>   group by JobAct.OurInvID, jobheads.JobID, JobHeads.LabourID ,Labour.Text  ;
>   order by JobAct.OurInvID, jobheads.JobID, JobHeads.LabourID ; 
>   into cursor JobsS
>
>>I'm trying to achieve the report below:
>>
>>
>>                      Derek                         Bob                      Angus          ...
>>Inv. No.  Booked   Charged   Booked   Charged  Booked   Charged 
>>_____   ______    _______   ______    _______   ______    _______
>>1        0.75       0.75
>>2                               6         5.5      12         11
>>3        20.5       20.5                   
>>...
>>
>>
>>So I need to sum the hours worked on a job, under each invoice ID, for each employee (JobAct.Hours), versus the hours required for each (JobHeads.Quantity)
>>
>>First I'm getting "command contains unrecognised phrase/keyword" and I can't figure what's up.
>>
>>Here's my pathetic attempt at the SQL. I've come to realise that I could really do with a course on this. I can't tell how successful it is as it won't work but I'm sure it's no good.
>>
>>
>>Select	JobAct.OurInvID,  JobHeads.JobID, JobHeads.LabourID, ;
>> 		SUM( jobheads.Quantity) as Booked, SUM( jobact.hours) as Charged,  ;
>> 		Labour.Text ;
>>  from jobheads ;
>>  Where jobheads.JobID = "RTvo" ;
>>  and not EMPTY( JobAct.OurInvID) ;
>>  INNER JOIN JobAct ;
>>  	ON  jobheads.JobID = jobact.JobID ;
>>  INNER JOIN Labour ;
>>    ON  Jobheads.LabourID = Labour.ID ;
>>   group by JobAct.OurInvID, jobheads.JobID, JobHeads.LabourID ,Labour.Text  ;
>>   order by JobAct.OurInvID, jobheads.JobID, JobHeads.LabourID ; 
>>   into cursor JobsS
>>
>>
>>A help would be much appreciated.
>>
>>Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform