Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Building a Simple Query (Newbie)

Status
Not open for further replies.

caper11752

IS-IT--Management
May 6, 2008
26
CA
Hi all,

I have a table called tblCodes that looks something like this:

Date Code Acct#
1/1/2010 WP41 985744
1/1/2010 WI03 754841
1/1/2010 WP41 545412
1/1/2010 WP41 747477
1/1/2010 WI03 212788
1/2/2010 WI03 124254
1/2/2010 WI03 714725
1/2/2010 WP41 996525

I need to build a query that will return results that will look something like this:

Date WP41_Count WI03_Count
01/01/2010 3 2
01/02/2010 1 2

I am VERY new to SQL and would appreciate the help. Basically, I need to produce a report that will give a daily count of each "Code".

Thanks in advance.
 
That is not so easy as you think :)
You easy can get a result like this;
[tt]
Date Code Count
01/01/2010 WP41 3
01/01/2010 WI03 2
01/02/2010 WP41 1
01/02/2010 WI03 2
[/tt]
But converting it to PIVOT is not so easy even with PIVOT command introduced in SQL Server 2005, just because you SHOULD know beforehand WHICH coeds will be involved in the result of the query.


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top