Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

How to Create a Dynamic Crosstab Query?

$
0
0

Hi friends,

I have a table like:

 

DateOfSale   SalesPerson    SalesAmount

 

Which may have any number of sales' staff (old/new workers) who have sold goods on different dates which may range atany length of time.

 

Any suggestion for an appropriate query / method to derive a crosstab / pivot result as

 

SalesPerson   Year1   Year2   Year3

 

With field SalesPerson representingeach of the staff member and all the amounts addedin terms of years, whatever the range may exist in time, instead of providing names and years in a hard-coded manner?

 

Looking forward for your expert advices.

 

Thanx in advance.


Best Regards, Faraz A Qureshi


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>