Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Beginner help with SQL select issue
Message
From
26/01/2010 13:30:53
 
 
To
26/01/2010 13:28:51
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
MS SQL Server
Miscellaneous
Thread ID:
01446019
Message ID:
01446023
Views:
65
In this case, adding will be the same as counting...

SELECT WorkerName, SUM(Job1), SUM(Job2) GROUP BY WorkerName

>Due to my beginner's knowledge of SQL Syntax, I am struggling with creating the following query to pass to SQL Server:
>
>Assume I have a simple table with 4 columns:
>
> workername
> Job 1 performed (0 or 1)
> Job 2 performed (0 or 1)
> Date entered
>
>with multiple entries for each name as work is performed on different days.
>
>I want a query which returns rows of 3 columns:
>
> workername
> Count of the number of times job 1 is performed (set to 1)
> Count of the number of times job 2 is performed (set to 1)
>
>with one row for each unique name.
>
>I understand how to do this if I only wanted one "count" column:
> SELECT workername , count(*) FROM WORKAUD where job1 = 1 group by workername
>
>But how can I include the count for job2 also?
>
>Thanks,
>Pat
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform