Hello All,
I am in a grave problem. First, following is my table description called csd
Some data are as follows
From this data i want to retrieve only those whose date matches the current date. If for any cust_id, current date is not there it should retrieve the immediate previous date. In essence, the query will retrieve data for current date if it is there, otherwise it will retrieve data for previous date.
I tried the following query, but it retrieve both the current date and previous date data for all cust ids.
Please help me in solving this query :eek:
Regards
alimdyusuf
I am in a grave problem. First, following is my table description called csd
Code:
Column Name Data Type
cust_id bigint
reading bigint
read_date date
Code:
cust_id reading read_date
111 1505 2013-05-05
111 1510 2013-05-12
124 1620 2013-05-05
124 1700 2013-05-06
I tried the following query, but it retrieve both the current date and previous date data for all cust ids.
Code:
select distinct t.cust_id,t.reading,t.read_date from csd t where t.read_date=curdate() or exists(select read_date from csd where read_date<curdate());
Regards
alimdyusuf