Testdaten zu holen:SQL-Abfrage alle Ergebnisse in einer Abfrage
id date company location
----------------------------------
1 03/01/2016 ABC india
2 03/25/2016 ABC us
3 02/24/2016 ABC india
4 02/25/2016 ABC us
5 03/02/2016 ABC india
Abfrage # 1
select count(id)
from table
where company = 'ABC'
and date between 03/01/2016 and 03/31/2016
Abfrage # 2
select count(id)
from table
where company = 'ABC'
and date between 02/01/2016 and 02/29/2016
Brauchen Lage weise Zählung berechnen für aktuelle und vorherige Monate. Wie schreibe ich eine SQL-Abfrage, um den Standort wie in einer Abfrage zurückzugeben?
Erwartetes Ergebnis:
company currentmonth Previousmonth location
ABC 2 1 india
ABC 1 1 us
es hilft nicht, konnten Sie Testdaten in Form der Tempentabelle zur Verfügung stellen, die Ihren erwarteten Daten entspricht? – TheGameiswar