एक विकल्प TO_CHAR . का उपयोग करता है :
select electrcityUsage, waterUsage
from monthlyBill
where accountNumber = '211' and
to_char(billing_date, 'MM-YYYY') = '12-2012'
यह मानता है कि आप वास्तव में Oracle का उपयोग कर रहे हैं, न कि SQL सर्वर का।
अगर आप चाहते थे 2012 और 2011 तो बस आगे बढ़ें और WHERE . में एक और शर्त जोड़ें खंड। मैं EXTRACT का उपयोग कर सकता हूं इस मामले में:
select electrcityUsage, waterUsage
from monthlyBill
where accountNumber = '211' and
extract(month from billingDate) = 12 and
extract(year from billingdate) in (2011, 2012)