Click here to Skip to main content
15,031,145 members
Home / Discussions / Database
   

Database

 
GeneralRe: Looking for advice on key/value storage options Pin
Chris Maunder16-Jul-21 16:19
cofounderChris Maunder16-Jul-21 16:19 
AnswerRe: Looking for advice on key/value storage options Pin
Gerry Schmitz9-Aug-21 6:04
mveGerry Schmitz9-Aug-21 6:04 
GeneralRe: Looking for advice on key/value storage options Pin
Chris Maunder9-Aug-21 6:22
cofounderChris Maunder9-Aug-21 6:22 
QuestionOpen Office Database Pin
Bram van Kampen1-Jul-21 14:26
MemberBram van Kampen1-Jul-21 14:26 
AnswerRe: Open Office Database Pin
Richard MacCutchan1-Jul-21 21:04
mveRichard MacCutchan1-Jul-21 21:04 
GeneralRe: Open Office Database Pin
Bram van Kampen2-Jul-21 14:54
MemberBram van Kampen2-Jul-21 14:54 
QuestionSelect with pivot Pin
Ismael Oliveira 202119-Jun-21 18:25
MemberIsmael Oliveira 202119-Jun-21 18:25 
AnswerRe: Select with pivot Pin
CHill6023-Jun-21 4:50
mveCHill6023-Jun-21 4:50 
"None of these worked" because the syntax for PIVOT[^] clearly states
Quote:
PIVOT
(
<aggregation function="">(<column being="" aggregated="">)
So just put the results of the PIVOT into a sub-query or a Common Table Expression or temporary table or a table variable, then manipulate that data. E.g.
SQL
;with cte as 
(
	select isnull([1], 0) as Janeiro,
		   isnull([2], 0) as Fevereiro,
		   isnull([3], 0) as Março,
		   isnull([4], 0) as Abril,
		   isnull([5], 0) as Maio,
		   isnull([6], 0) as Junho,
		   isnull([7], 0) as Julho,
		   isnull([8], 0) as Agosto,
		   isnull([9], 0) as Setembro,
		   isnull([10], 0) as Outubro,
		   isnull([11], 0) as Novembro,
		   isnull([12], 0) as Dezembro
	from (select month(PP.PAPA_DT_DATAPAGAMENTO) as Mesn, PP.PAPA_RE_VALORPAGAMENTO from PAGAMENTO_PARCELA PP
	inner join PAGAMENTO P on PP.MOVI_NA_CODIGO = P.MOVI_NA_CODIGO 
	where P.SUPA_NA_CODIGO = 5) Tab1
	pivot (sum(PAPA_RE_VALORPAGAMENTO) for Mesn in  ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])) P1
)
select  0.95 * Janeiro,0.95 * Fevereiro,0.95 * Março,0.95 * Abril,
		0.95 * Maio,0.95 * Junho,0.95 * Julho,0.95 * Agosto,
		0.95 * Setembro,0.95 * Outubro,0.95 * Novembro,0.95 * Dezembro
from cte;
Couple of other points to note
- I've changed the JOIN to use an ON clause rather than defining the join using the WHERE clause. Your style is quite old-fashioned and prevents you from using OUTER joins
- It's a lot easier to answer questions like this if you supply the table schemas and some sample data along with your expected results. And always be specific - "None of these worked" is not helpful. "I get an error reported 'Incorrect syntax near '0.95'.' might have got you an answer quicker
GeneralRe: Select with pivot !! Pin
User 1407655213-Jul-21 21:34
MemberUser 1407655213-Jul-21 21:34 
GeneralRe: Select with pivot !! Pin
CHill6014-Jul-21 3:50
mveCHill6014-Jul-21 3:50 
GeneralRe: Select with pivot !! Pin
User 1407655214-Jul-21 3:58
MemberUser 1407655214-Jul-21 3:58 
GeneralRe: Select with pivot !! Pin
CHill6014-Jul-21 4:09
mveCHill6014-Jul-21 4:09 
QuestionAbout MySQL table permission removal failed Pin
Member 1105472311-Jun-21 8:00
MemberMember 1105472311-Jun-21 8:00 
AnswerRe: About MySQL table permission removal failed Pin
Richard Deeming13-Jun-21 22:09
mveRichard Deeming13-Jun-21 22:09 
QuestionSandwich Query For Employee Attendance using SQL Server 2005 Pin
Mohammad Salmani8-Jun-21 20:40
MemberMohammad Salmani8-Jun-21 20:40 
AnswerRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
Richard MacCutchan8-Jun-21 21:55
mveRichard MacCutchan8-Jun-21 21:55 
AnswerRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
SeeSharp29-Jun-21 1:35
MemberSeeSharp29-Jun-21 1:35 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
Mohammad Salmani9-Jun-21 3:08
MemberMohammad Salmani9-Jun-21 3:08 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
SeeSharp29-Jun-21 3:39
MemberSeeSharp29-Jun-21 3:39 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
David Mujica9-Jun-21 4:25
MemberDavid Mujica9-Jun-21 4:25 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
Mycroft Holmes9-Jun-21 12:36
professionalMycroft Holmes9-Jun-21 12:36 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
SeeSharp210-Jun-21 1:25
MemberSeeSharp210-Jun-21 1:25 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
Mycroft Holmes10-Jun-21 12:09
professionalMycroft Holmes10-Jun-21 12:09 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
Mohammad Salmani10-Jun-21 21:53
MemberMohammad Salmani10-Jun-21 21:53 
GeneralRe: Sandwich Query For Employee Attendance using SQL Server 2005 Pin
SeeSharp211-Jun-21 1:20
MemberSeeSharp211-Jun-21 1:20 

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.