In this table there are three colum and in need the value for of data which are lesser than code = 28,this is my query
x
SELECT value,code,date
FROM table
order by date,vchcode
but when i ad where clouse like
SELECT value,code,date
FROM table
where code < 28
order by date,vchcode
is only shows 2 row with code 26 and 27… i need 26,27 and 32.. and table colums are variable its not fix..
Advertisement
Answer
I think you wnat to take the date into account — what you really want are all rows before the date of the row with code 28
.
One method uses a subquery:
SELECT t.value, t.code, t.date
FROM table t
WHERE date < (SELECT date FROM table t2 WHERE t2.code = 28)
ORDER BY t.date, t.vchcode