datetime century date into pad dynamic cursor money percent sp job isnumeric isdate over update
SQLUSA.com
SQL 2008 GRAND SLAM ON 49 CD
FREE TRIAL  CLICK HERE TO ORDER  SEARCH
SQL Server Training SQL 2005 Scripts SQL 2008 Articles
SQL JOBS News Format Developer
How to check the YTD performance of the sales reps?

Execute the following SQL Server T-SQL script in SSMS Query Editor to list YTD and Last Year sales by rep:

USE AdventureWorks2008;

 

SELECT row_number()

         OVER(PARTITION BY CountryRegionName ORDER BY SalesYTD ASC) AS SeqNo,

       CountryRegionName,

       FirstName,

       LastName,

       JobTitle,

       SalesYTD = '$' + convert(VARCHAR,SalesYTD,1),

       SalesLastYear = '$' + convert(VARCHAR,SalesLastYear,1)

FROM   Sales.vSalesPerson

 

SeqNo CountryRegionName FirstName LastName JobTitle SalesYTD SalesLastYear
1 Australia Lynn Tsoflias Sales Representative $1,758,385.93 $2,278,548.98
1 Canada Garrett Vargas Sales Representative $1,764,938.99 $1,620,276.90
2 Canada José Saraiva Sales Representative $3,189,356.25 $2,038,234.65
1 France Ranjit Varkey Chudukatil Sales Representative $3,827,950.24 $2,396,539.76
1 Germany Rachel Valdez Sales Representative $2,241,204.04 $1,307,949.79
1 United Kingdom Jae Pak Sales Representative $5,015,682.38 $1,635,823.40
1 United States Pamela Ansman-Wolfe Sales Representative $0.00 $1,927,059.18
2 United States Syed Abbas Pacific Sales Manager $219,088.88 $0.00
3 United States Amy Alberts European Sales Manager $636,440.25 $0.00
4 United States Stephen Jiang North American Sales Manager $677,558.47 $0.00
5 United States Tete Mensa-Annan Sales Representative $1,931,620.18 $0.00
6 United States Tsvi Reiter Sales Representative $2,811,012.72 $1,849,640.94
7 United States Shu Ito Sales Representative $3,018,725.49 $2,073,506.00
8 United States David Campbell Sales Representative $3,587,378.43 $1,371,635.32
9 United States Jillian Carson Sales Representative $3,857,163.63 $1,997,186.20
10 United States Michael Blythe Sales Representative $4,557,045.05 $1,750,406.48
11 United States Linda Mitchell Sales Representative $5,200,475.23 $1,439,156.03

 

Order SQL 2008 GRAND SLAM Today!
SQLUSA.com Home Page
SQL Server Training at www.sqlusa.com.
Microsoft SQL Server 2012 Training Videos at www.sqlusa.com.
SQL Server 2008 Video Training at www.sqlusa.com.
SQL Server 2005 Training Videos at www.sqlusa.com.
Accounting
Administrative
Advertising
Arts
Architecture
Banking
Business Intelligence
Career Jobs
Celebrity
Computer
Consulting
Customer Service
Education
Engineering
Entertainment
Entry Level
Executive
Federal
Finance
Government
Hardware
Healthcare
Hospital
Human Resources
Information Technology
Insurance
Internet
Job Openings
Laboratory
Law Enforcement
Legal
Logistics
Manufacturing
Marketing
Medical
Military
Nursing
Pharmaceutical
Physician
Public Relations
Publishing
Real Estate
Restaurant
Retail
Sales
Social Media
Software
SQL Database
Telecomm
Therapist
Training
Transportation
Truck Driver
Travel
Web
Work from Home

FREE SS SQL / BI OLAP Short Videos on YOUTUBE.com

Microsoft Community Contributor 2011 Microsoft Community Contributor 2012

Search SQLUSA FREE SQL Server Articles & FREE T-SQL Scripts

JOIN US ON TWITTER

Copyright 2005-2012, SMI Corp. All Rights Reserved.

SQL Server 2012 is a program product of Microsoft Corporation.
SQL Server 2008 is a program product of Microsoft Corporation.
SQL Server 2005 is a program product of Microsoft Corporation.
SQL Server 2000 is a program product of Microsoft Corporation.