Click here to Skip to main content
16,018,650 members

Comments by User-10031173 (Top 37 by date)

User-10031173 20-Dec-13 7:45am View    
in rm_price table sid is also there i forgot to mention sid
User-10031173 20-Dec-13 7:44am View    
sid is the reference key
User-10031173 20-Dec-13 5:33am View    
but its giving error like:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'SELEC
T @maxprice = MAX(unitprice) FROM rm_price
SELECT rmname, @minprice as MinP' at line 2
User-10031173 20-Dec-13 5:21am View    
I tried the below query. giving correct result, but i need current unitprice and respective inv_date,sname group by sname. how can i place these in the follwing query. please help me

select r.sid,r.rmname,r.inv_date as dateofmax,
r.unitprice as maxprice,
r3.inv_date as minofdate,r3.unitprice as minprice,
r.unitprice-r3.unitprice as pricediff
from rm_price r
left join rm_price r2 on r.rmname=r2.rmname and r.unitprice<r2.unitprice
left="" join="" rm_price="" r3
="" on="" r.rmname="r3.rmname" and="" r3.unitprice<="r.unitprice
" r4=""
="" r3.unitprice="">r4.unitprice
where r2.unitprice is null
and r4.unitprice is null group by r.rmname \G
User-10031173 20-Dec-13 5:16am View    
its correct.
also i need current price and respective date,sname and group by suppliername for above query. where can i place these columns. i tried many ways but giving wrong results.