Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pivot this 2 tables?
Message
De
19/09/2015 09:55:25
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
How to pivot this 2 tables?
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01624819
Message ID:
01624819
Vues:
68
Good morning, please help me with the following, I have two tables that I need to pivot or join themselves in a new table, the columns with data for existing tables are: (First two tables are the source and I need to create the third table as a result)
TOTAL QUOTES BY DAY (this is the total quotes for a giving client by day)
date       client 	quotes
09-10-15	18Ce 	215	
09-11-15	18Ce 	151	
09-12-15	18Ce 	193	
09-13-15	18Ce 	4	
09-14-15	18Ce 	172	
09-15-15	18Ce 	278	
09-16-15	18Ce 	160	
09-17-15	18Ce 	212	

TOTAL CANCELATIONS BY DAY  (total cancelation request and description by day same client)
date		problem				qty
09-10-15	Declined at begining	         2
09-11-15	Declined at begining	         3
09-12-15	Declined at begining	         2
09-14-15	Declined at begining	         3
09-15-15	Declined at begining	         3
09-16-15	Declined at begining	         2
09-17-15	Declined at begining	        2
09-10-15	Not Ended				2
09-11-15	Not Ended				2
09-12-15	Not Ended				1
09-13-15	Not Ended				2
09-14-15	Not Ended				3
09-15-15	Not Ended				4
09-16-15	Not Ended				3
09-17-15	Not Ended				3
09-10-15	No Credit Card			3
09-11-15	No Credit Card			2
09-12-15	No Credit Card			1
09-13-15	No Credit Card			1
09-14-15	No Credit Card			2
09-15-15	No Credit Card			5
09-16-15	No Credit Card			3
09-17-15	No Credit Card			3

This is the result table that I need, each cancelation request as a column and add the total by day in the respective day)

TOTAL QUOTES BY DAY WITH CANCELATIONS
date       client 	quotes               Declined at begining	                Not Ended	      No Credit Card
09-10-15	18Ce 	215				2					2			3
09-11-15	18Ce 	151				3					2			2
09-12-15	18Ce 	193				2					1			1
09-13-15	18Ce 	4									2			1
09-14-15	18Ce 	172				3					3			2
09-15-15	18Ce 	278				3					4			5
09-16-15	18Ce 	160				2					3			3
09-17-15	18Ce 	212				2					3			3
TIA.
John Harold Belalcázar Lozano
Associate Director Of Development
http://www.belvicto.co/
jhbelalc@gmail.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform