Home » SQL & PL/SQL » SQL & PL/SQL » Date function (Oracle 11g)
Date function [message #423278] Wed, 23 September 2009 03:41 Go to next message
Messages: 50
Registered: October 2007
Location: Silvassa
I need a date function in SQL to calculate the avg sale qty on any given from the month of April.

Please help.

Re: Date function [message #423280 is a reply to message #423278] Wed, 23 September 2009 03:45 Go to previous messageGo to next message
Messages: 3202
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Well. it's probably "avg", "to_date", "trunc", "group by" or "extract". Possibly even "where".

Depending on what you actually mean with that question.

[Updated on: Wed, 23 September 2009 03:45]

Report message to a moderator

Re: Date function [message #423295 is a reply to message #423278] Wed, 23 September 2009 04:28 Go to previous message
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
About the only sensible question I can derive from what you've written is 'I need to be able to calculate the average sale quantity from the month of April for a set of rows from my table'

Assuming this is the case, try
SELECT avg(quantity)
FROM <table>
WHERE extract(month from <your date column>) = 4

Previous Topic: how sql fetches records from diffrent partitions of table
Next Topic: Determine Explain Plan for a SQL run several hours prior
Goto Forum:

Current Time: Wed Aug 16 14:44:20 CDT 2017

Total time taken to generate the page: 0.17883 seconds