Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Count Distinct
Message
From
25/09/2014 01:33:10
 
 
To
24/09/2014 19:51:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01608230
Message ID:
01608240
Views:
53
>Having a senior moment.........
>
>I have a table with the following data
>OWNER          DEPT
>1                          A
>1                          A
>1                          A
>2                          A
>2                          B
>3                          B
>3                          B
>3                          B
>3                          C
>
>and I need to get a count of how many departments there are for each owner
>OWNER       NUM_DEPTS
>1                        1     (A)
>2                        2     (A/B)
>3                        2     (B/C)
>
>In VFP 9 I would do something like
>SELECT aa.owner,COUNT(*) AS num_depts FROM (select DISTINCT owner,dept FROM myCursor) aa GROUP BY 1
>
>but I'm having trouble remembering how to do this in one statement in VFP 8
>
>All replies welcome.
>
>Thanks............Rich
select Owner, count(distinct Dept ) ;
	from myCursor ;
	group by 1
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform