Estou enfrentando um problema, eu possuo dois selects sql
select *
from web.demonstrativo_processados
where nroempresa = 1
and data between to_date('2018/01/01' , 'yyyy/mm/dd')
and to_date('2018/12/31' , 'yyyy/mm/dd')
que me trás os valores do ano de 2018 e tenho este:
select *
from web.demonstrativo_processados
where nroempresa = 1
and data between to_date('2017/01/01' , 'yyyy/mm/dd')
and to_date('2017/12/31' , 'yyyy/mm/dd')
Que retorna os valores de 2017.
Eu gostaria que viesse como resposta estas duas colunas, por isso preciso integrar os 2 selects.
Como estou usando o php e o google charts para gerar gráficos, iria me facilitar muito o trabalho. gráfico que pretendo fazer
Obrigado
WHILE DO MEU PHP
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Mês', '2017', '2018'],
<?php
include ("./conexao_local.php");
$sql = "select * from web.demonstrativo_processados where nroempresa = 1 and data between to_date('2017/01/01' , 'yyyy/mm/dd') and to_date('2017/12/31' , 'yyyy/mm/dd')";
$stmt = oci_parse($conexao, $sql);
oci_execute($stmt);
while (($array = oci_fetch_array($stmt, OCI_BOTH)) != false) {
$valorvenda = $array["VLRVENDA"];
$valorvenda1 = str_replace(",",".", $valorvenda);
?>
['Mês 2017', <?php echo $valorvenda1 ?>,400],
<?php } ?>
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
vAxis: {minValue: 0}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div_1'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div_1" style="width: 100%; height: 500px;"></div>
</body>
</html>
COUNT
,SUM
, etc, depoisGROUP BY
. Tente melhorar sua pergunta, inserir mais detalhes, pois ficou ampla. – rbz 26/10/18 às 18:43