FOROS PROFESIONALES
WINDEV
,
WEBDEV
y
WINDEV Mobile
Inicio
|
Mensajes recientes
|
Conéctese...
|
Desconectar
|
Español
Inicio
→
WINDEV 2024
→
WD21 - How to negate a value when defining a Query
WD21 - How to negate a value when defining a Query
Iniciado por Sam Asid, 20,jun. 2017 11:50 - 2 respuestas
Conéctese…
Sam Asid
#1
Publicado el 20,junio 2017 - 11: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.
Sam
Informar
0
0
Allard
#2
Publicado el 21,junio 2017 - 17:16
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
regards
Allard
Informar
0
0
Arie
#3
Publicado el 22,junio 2017 - 10:03
Sam,
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}
UNION ALL
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.
Informar
0
0
→ Volver a WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versiones precedentes)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Búsqueda Tipo
Sólo temas
Todos los mensajes
Periodo Buscar
Cualquier fecha
Última hora
Última 24 horas
Última semana
Último mes
Último año
Cancelar
Vista previa del mensaje
Añadiendo una imagen
Importar una imagen desde una URL
Enviar una imagen desde un archivo de su disco
Arrastrar un archivo o click en "Examinar..."
o
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto