Home » SQL & PL/SQL » SQL & PL/SQL » Result of quesry
Result of quesry [message #387241] Wed, 18 February 2009 07:43 Go to next message
rajesh_css
Messages: 1
Registered: February 2009
Junior Member
Hi,

I have a table X with 3 columns name ,date(YYYYMMDD),total


name--date--total


x---02Jan2009--1
y---06Jan2009--1
z---10Jan2009--1
x---01Oct2008--1
x---03Nov2008--1
y---22Dec2008--1
x---02Feb2009--1
y---22Feb2009--1
z---03Feb2009--1
z---04Feb2009--1


select Name,count(total) from X where
TO_CHAR(date,'YYYYMM') = (TO_CHAR(TO_DATE
('20090201','YYYYMMDD'),'YYYYMM'))
Group BY Name


i will get the result as


Name--Month total
x--1
y--1
z--2


i need to write a query in such a way that i need to get the result
for that year which is in between 200901 to 200902 (the count of the
selectee month and the previous months of the year)


Name--month total--year total


x--1--2
y--1--2
z--2--3


Regards
Raj


Re: Result of quesry [message #387242 is a reply to message #387241] Wed, 18 February 2009 07:46 Go to previous messageGo to next message
joy_division
Messages: 4641
Registered: February 2005
Location: East Coast USA
Senior Member
Hint:
select to_char(sysdate,'Month'),to_char(sysdate,'YYYY') from dual;


Re: Result of quesry [message #387250 is a reply to message #387241] Wed, 18 February 2009 08:23 Go to previous message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a Test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Previous Topic: Cursor
Next Topic: Need help on Update SQL...
Goto Forum:
  


Current Time: Tue Dec 06 16:22:37 CST 2016

Total time taken to generate the page: 0.22783 seconds