Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

get updated data

$
0
0

Hi,

In the below query im expecting distinct CPSTatus and CPStatusCmmetns but  it displays duplicate SChedule

SELECT Stuff((SELECT Distinct [CPStatus] +' \n ' + [CPStatusComments] FROM

[EFIWorkStatus1] WHERE [ST_ID] = a.[ST_ID] AND [CPStatus] <> 'Select' FOR xml

path('')), 1, 0, '') [CPStatusComments] FROM [EFIWorkStatus1] a

WHERE ST_ID=1 GROUP BY [ST_ID]

Output for above query On Hold \n test on onhold

\nSchedule \n test in Close Out &#x0D; Package schedule

\nSchedule \n test in Close Out is done Package schedule

Data in table CPStatus     CPStatusComments

Schedule   test in Close Out   Package schedule
Schedule   test in Close Out   Package schedule
Schedule   test in Close Out   Package schedule
Schedule   test in Close Out is done Package schedule
On Hold   test on onhold 

How can i display most updated data  in the query  for schedule  " Schedule   test in Close Out is done Package schedule". Any suggestions please.

expected Output:

Schedule \n test in Close Out is done Package schedule\nOn Hold\n   test on onhold


Viewing all articles
Browse latest Browse all 4729

Trending Articles



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