Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr
Letzter Beitrag:
vor 12 Monaten
Beteiligte Autoren:
Arie, Allard, Sam Asid

WD21 - How to negate a value when defining a Query

Startbeitrag von Sam Asid am 20.06.2017 09:50

Hello All,

I trust this finds you all well.

I am building two queries to be used in a join. I would like to query data from two different months. For one month I want the values to be positive (+ve) and the other month Negative (-ve). I want to build a report out of the 'joined queries' such that query1.value+query2.value will give me the net of the two [ query1.value(+ve) + query2.value (-ve) ]=Net.

How do I get the queryvalue "negated" in the query builder?

Thanks in advance.



1 Make the two queries by selecting the right data. data --Between two dates -- You can select this in the editor or add two params Start date -- End ddate

-- greater then or equal to
-- less then or equal to

2 Add a calculated element to the list of elements.

Select this : CASE WHEN ? THEN ? [WHEN ? THEN ?] ELSE ? END

? after when add the row woth the positive data
? after then add the positive data agan but add a minus sign before

Should work


von Allard - am 21.06.2017 15:16

you could also use a UNION for that

SELECT SUM(netvalue) as netvalue, othervalue1, othervalue2 FROM
SELECT table1.value as netvalue, othervalue1, othervalue2 FROM table1 WHERE yourdate BETWEEN {paramd1} AND {paramd2}
SELECT (table2 .value*-1) as netvalue, othervalue1, othervalue2 FROM table2 WHERE yourdate BETWEEN {paramd3} AND {paramd4}
GROUP BY othervalue1, othervalue2

I'm not sure if you can do this using the GUI of the query editor. But you can create it in the sql-code-editor.

von Arie - am 22.06.2017 08:03
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.