Ich habe folgende TabelleWie Preisdifferenz von derselben Tabelle in SQL
slno date productid companyid price
88 2017-05-17 1 1 65.27
87 2017-05-17 1 2 72.94
86 2017-05-17 1 3 73.13
85 2017-05-17 2 1 73.73
84 2017-05-17 2 2 67.71
83 2017-05-16 1 1 65.40
82 2017-05-16 1 2 72.49
81 2017-05-16 2 1 73.31
80 2017-05-16 2 2 67.17
Jetzt mag ich Preis von Produkt 1 für 2017.05.17 und Differenz von Preis von gestern für gleiche Firma ID bekommen.
z:
getPrice(productid = 1, date='2017-05-17')
and this should return :
companyid , productid , date, price, difference from yesterday:
1, 1,'2017-05-17', 65.27, -0.13
2, 1,'2017-05-17', 72.94, 0.45
...
or it should return:
companyid , productid , date, price, yesterday price:
1, 1,'2017-05-17', 65.27, 65.40
2, 1,'2017-05-17', 72.94, 72.49
...
Wie dies in PHP SQL bekommen?
zu erhalten Von Ihnen wird erwartet, dass Sie ** den Code selbst schreiben **. Nach [** mehr Forschung **] (https://meta.stackoverflow.com/q/261592/1011527) Wenn Sie ein Problem haben ** posten Sie, was Sie versucht haben ** mit einer ** klaren Erklärung von was funktioniert nicht ** und bietet [ein minimales, vollständiges und überprüfbares Beispiel] (http://stackoverflow.com/help/mcve). Lesen Sie [Wie Sie fragen] (http://stackoverflow.com/help/how-to-ask) eine gute Frage. Achten Sie darauf, [die Tour zu besuchen] (http://stackoverflow.com/tour) und lesen [this] (https://meta.stackoverflow.com/q/347937/1011527). –
Ich brauche SQL dafür. – Rajesh