Click here to Skip to main content
15,884,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Experts,
i have a table in the following format
Date               Node  KPI1  KPI2  KPI3
2012-10-11         RNC1   2    5      10
2012-10-11         RNC2   3    5      12
2012-10-11         RNC3   2    6      10
2012-10-12         RNC1   9    1      16
2012-10-12         RNC2   6    2      10

I want to diplay it this way
Node  KPI    2012-10-11 2012-10-12
RNC1  KPI1   2           9
RNC1  KPI2   5           1
RNC1  KPI3   10         16
RNC2  KPI1   3           2

Please suggest how to do this in sql.

Thanx
Posted
Updated 17-Oct-12 21:11pm
v2

Your query will return unique DATES, as you've specified. If you want to get just unique MONTHS/YEARS, you should either modify you dates in a way, that each date becomes the first day of the month, or you should just go with some string representation like 'YYYY-MM'. Sorry, I can't write you an exact code how to do this, as I do not develop on mysql, but I think this should get you somewhere :)
SQL
SELECT DISTINCT YEAR(date_posted), MONTH(date_posted) FROM table
 
Share this answer
 
v2
Comments
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900