Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / August 2005

Tip: Looking for answers? Try searching our database.

simple or not?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
federico - 29 Aug 2005 21:10 GMT
The simple(?) problem is:

We have a Table 'Batch', with 2 columns: Batch and State, with this data:

Batch   State
A       3
A       1
A       1
B       2
B       2
B       3
C       1
C       1
C       2

and we want this return

Batch   State 1    State 2   State 3
A         2           0         1
B         0           2         1
C         2           1         0

counting the number of lines in each state grouped by Batch

Which is the SQL command to do that?, simple or not?
Sylvain Lafontaine - 29 Aug 2005 21:31 GMT
Is the number of states 1, 2 and 3 fixed or not?

If it's fixed, a simple Group By associated with a 3 Sum() over 3 Case
statements will do the trick, otherwise it's more complicated; as SQL-Server
doesn't offer a direct support for Pivot transformation.

Signature

Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF

> The simple(?) problem is:
>
[quoted text clipped - 21 lines]
>
> Which is the SQL command to do that?, simple or not?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.