Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 RETURN RESULTS ON A SINGLE ROW INSTEAD OF MULTIPLE

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-11-25 : 18:49:01
I HAVE A TABLE WITH 8 COLUMNS

ID, DESCRIPTION, STATUS_CMA, STATUS_CAP, STATUS_CED, STATUS_CCT, DATE_CMA, DATE_CAP, DATE_CED, DATE_CCT

SOMEONE CAN LOGIN AND MAKE CHANGES TO ANY ONE OF THE STATUSES.
THERE ARE FOUR DISTINCT DESCRIPTIONS (CMA, CAP, CED, CCT)

EXAMPLE THE SAME ID CAN BE IN THE table MULTIPLE TIMES
FOR EACH ENTRY. i WOULD LIKE TO PUT EVERYTHING ON ONE LINE INSTEAD OF HAVING THE SAME ID IN 3 OR 4 DIFFERENT ROWS

MY FIELDS ARE ID, DESCRIPTION,STATUS_CMA,STATUS_CAP,STATUS_CED, STATUS_CCT , DATE_CMA, DATE_CAP, DATE_CED, DATE_CCT


SO I COULD SO I COULD DO A SELECT ID, DESCRIPTION, CASE WHEN DECCRIPTION = 'CMA' THEN STATUS_CMA ,CASE WHEN DECCRIPTION = 'CAP'THEN STATUS_CAP
CASE WHEN DECCRIPTION CED THEN STATUS_CCC, CASE WHEN = CCT THEN STATUS_CCT, MAX(DATE_CMA), MAX(DATE_CAP), MAX(DATE_CED), MAX(DATE_CCT)
FROM INFORMATION
group by SELECT ID, DESCRIPTION

please assist where you CAN

HOWEVER I STILL GET 3 ROWS I ONLY WANT ONLY ONE

Muj9
Yak Posting Veteran

75 Posts

Posted - 2014-11-26 : 05:24:36
PLEASE SHOW YOUR CURRENT TABLE RESULT AND YOUR EXPECTED RESULT




Go to Top of Page
   

- Advertisement -