Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 17-Oct-12 21:04pm
Edited 17-Oct-12 21:11pm
Mehdi Gholam231.3K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 Smile | :)
SELECT DISTINCT YEAR(date_posted), MONTH(date_posted) FROM table
  Permalink  
v2
Comments
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 430
1 DamithSL 288
2 Sergey Alexandrovich Kryukov 220
3 Peter Leow 215
4 Maciej Los 195


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid