Click here to Skip to main content
15,889,842 members
Home / Discussions / Database
   

Database

 
AnswerRe: Display data only from search parameters Pin
rattlerrFx23-May-17 13:21
rattlerrFx23-May-17 13:21 
GeneralRe: Display data only from search parameters Pin
CHill6024-May-17 1:06
mveCHill6024-May-17 1:06 
QuestionTeam Please help on the below request Pin
ganesh_naganna23-May-17 0:55
ganesh_naganna23-May-17 0:55 
AnswerRe: Team Please help on the below request Pin
Mycroft Holmes23-May-17 14:55
professionalMycroft Holmes23-May-17 14:55 
QuestionSQL for dynamic mappings Pin
Danpeking22-May-17 3:13
Danpeking22-May-17 3:13 
QuestionRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:19
mveCHill6022-May-17 4:19 
AnswerRe: SQL for dynamic mappings Pin
Danpeking22-May-17 4:30
Danpeking22-May-17 4:30 
AnswerRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:27
mveCHill6022-May-17 4:27 
Assuming you get the data sorted out then something like the following will work
SQL
SELECT * FROM
 (
	SELECT C.ClientID, ClientName, StatusDescription, 
	CASE WHEN SM.StatusID IS NOT NULL THEN 'Y' ELSE 'N' END AS Actual
	FROM @Clients C
	LEFT OUTER JOIN @Statuses S ON C.ClientID = S.ClientID
	LEFT OUTER JOIN @StatusMappings SM on SM.StatusID = S.StatusID
) qry
PIVOT 
(
	MAX(Actual) FOR StatusDescription in ([Draft Letter],[Awaiting Response],[Complete])
) pvt
WHERE ClientName = 'Barclays'
If you want to use it in an SSRS report then put the query into a Stored Procedure, passing the Client name or id as a parameter.

If the Status Descriptions are not standard or consistent (i.e. not the ones listed) then you will have to use some dynamic sql.

There are articles here on CodeProject on all the topics above
GeneralRe: SQL for dynamic mappings Pin
Danpeking22-May-17 4:36
Danpeking22-May-17 4:36 
GeneralRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:39
mveCHill6022-May-17 4:39 
GeneralRe: SQL for dynamic mappings Pin
Danpeking22-May-17 5:46
Danpeking22-May-17 5:46 
AnswerRe: SQL for dynamic mappings Pin
Danpeking24-May-17 23:28
Danpeking24-May-17 23:28 
GeneralMessage Closed Pin
18-May-17 20:29
Member 1321003518-May-17 20:29 
GeneralRe: oracle fusion procurement Pin
Richard MacCutchan18-May-17 21:49
mveRichard MacCutchan18-May-17 21:49 
GeneralRe: oracle fusion procurement Pin
CHill6018-May-17 22:24
mveCHill6018-May-17 22:24 
GeneralRe: oracle fusion procurement Pin
Richard MacCutchan18-May-17 22:35
mveRichard MacCutchan18-May-17 22:35 
QuestionRun sql query inside a stored procedure Pin
Member 1320472716-May-17 9:29
Member 1320472716-May-17 9:29 
QuestionRe: Run sql query inside a stored procedure Pin
ZurdoDev16-May-17 10:13
professionalZurdoDev16-May-17 10:13 
AnswerRe: Run sql query inside a stored procedure Pin
Kornfeld Eliyahu Peter16-May-17 21:21
professionalKornfeld Eliyahu Peter16-May-17 21:21 
SuggestionRe: Run sql query inside a stored procedure Pin
Richard Deeming17-May-17 1:25
mveRichard Deeming17-May-17 1:25 
QuestionGet sum of column base on equality of values of one row From previous generate request( using SELECT and EXTRACT) Pin
Mostafazs14-May-17 20:35
Mostafazs14-May-17 20:35 
AnswerRe: Get sum of column base on equality of values of one row From previous generate request( using SELECT and EXTRACT) Pin
Maciej Los14-May-17 21:18
mveMaciej Los14-May-17 21:18 
GeneralRe: Get sum of column base on equality of values of one row From previous generate request( using SELECT and EXTRACT) Pin
Mostafazs15-May-17 17:40
Mostafazs15-May-17 17:40 
AnswerRe: Get sum of column base on equality of values of one row From previous generate request( using SELECT and EXTRACT) Pin
Maciej Los15-May-17 20:03
mveMaciej Los15-May-17 20:03 
GeneralRe: Get sum of column base on equality of values of one row From previous generate request( using SELECT and EXTRACT) Pin
Mostafazs16-May-17 20:04
Mostafazs16-May-17 20:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.