Active Topics Active Topics  Display List of Forum Members Memberlist  Invert Forum Background Colours Invert Colours  Search The Forum Search  Help Help  Register Register  Login Login
Sponsored by Beatnik Games
Hardware / Software Bits & Bobs
 |SFH| Sent From Hell :: Community Forums : Hardware / Software Bits & Bobs
Subject Topic: SQL help (orcale) (Topic Closed Topic Closed) Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
cannedfool
Imba Community Member
Imba Community Member


Joined: 07 July 2003
Location: United Kingdom
Posts: 522
Posted: 22 September 2006 at 10:02am | IP Logged  

im stuck and i need my lovely SFH friends hehe, (hopefully demon will see this he seems to know this kinda stuff (maybe gam gam's).

i have this sql query:

SELECT     ROWNUM - 61 AS MONTH, TO_CHAR(ADD_MONTHS(SYSDATE, 1 - 1 * ROWNUM + 60), 'MON YY') AS MONTH_LABEL
FROM         (SELECT     SYSDATE AS DATETODAY
                       FROM          DUAL
                       GROUP BY CUBE(1, 2, 3, 4, 5, 6, 7, 8)) DERIVEDTBL
WHERE     (ROWNUM < 120)

it basically creates a list of dates and index numbers:

 -60     SEP 11
 -59     AUG 11
 -58     JUL 11
 -57     JUN 11
 -56     MAY 11
 -55     APR 11
 -54     MAR 11
 -53     FEB 11
 -52     JAN 11
 -51     DEC 10
 -50     NOV 10

(this one does negative through to positive)

 

So the problem is CUBE is only supported by oracle 8.1 and my database doesnt use it, any anyone else think of a way to get this sequence of numbers without using cube.

cheers

Back to Top View cannedfool's Profile Search for other posts by cannedfool Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 22 September 2006 at 10:20am | IP Logged  

i think ur using the command in the wrong syntax

http://databases.about.com/od/sql/l/aacuberollup.htm

Funny you should ask about SQL, ive been doing lots of it this week, but my queries are much simpler, these ones filter a table of installed applications (the list you get in the Add/Remove Programs window), for windows hotfixes:

use eXpress;
SELECT computer.name as 'Server',application.name as 'Hotfix'
FROM application, computer
WHERE application.computer_id = computer.computer_id
AND
((application.name LIKE 'KB%') OR
(application.name LIKE 'Q1%') OR
(application.name LIKE 'Q2%') OR
(application.name LIKE 'Q3%') OR
(application.name LIKE 'Q4%') OR
(application.name LIKE 'Q5%') OR
(application.name LIKE 'Q6%') OR
(application.name LIKE 'Q7%') OR
(application.name LIKE 'Q8%') OR
(application.name LIKE 'Q9%') OR
(application.name LIKE 'Q0%'))
ORDER BY computer.name;


use eXpress;
SELECT computer.name as 'Server',COUNT(DISTINCT application.name) as 'Total Hotfixes' FROM application,computer
WHERE application.computer_id = computer.computer_id
AND
((application.name LIKE 'KB%') OR
(application.name LIKE 'Q1%') OR
(application.name LIKE 'Q2%') OR
(application.name LIKE 'Q3%') OR
(application.name LIKE 'Q4%') OR
(application.name LIKE 'Q5%') OR
(application.name LIKE 'Q6%') OR
(application.name LIKE 'Q7%') OR
(application.name LIKE 'Q8%') OR
(application.name LIKE 'Q9%') OR
(application.name LIKE 'Q0%'))
GROUP BY computer.name;



Edited by Demonboy on 22 September 2006 at 10:20am


__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
cannedfool
Imba Community Member
Imba Community Member


Joined: 07 July 2003
Location: United Kingdom
Posts: 522
Posted: 22 September 2006 at 10:30am | IP Logged  

its using a strange syntax but it just creates a large number of rows. it does work in a table we have on 8.1 but not on the 8.0.

i just found

SELECT     ROWNUM - 61 AS MONTH
FROM         USER_OBJECTS
WHERE     (ROWNUM < 60)

but its limited to the number of records in user_objects which is a shame.

still looking....



Edited by cannedfool on 22 September 2006 at 10:31am
Back to Top View cannedfool's Profile Search for other posts by cannedfool Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 22 September 2006 at 10:52am | IP Logged  

what exactly is it ur trying to generate?

__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
Mash-Tin_UK
Clan Member
Clan Member
Avatar

Joined: 21 September 2005
Location: United Kingdom
Posts: 1936
Posted: 22 September 2006 at 10:54am | IP Logged  

 LOL

__________________

Your tears fuel me     -      E .ďż˝ ` ' / ďż˝. F
Back to Top View Mash-Tin_UK's Profile Search for other posts by Mash-Tin_UK Send Private Message Add to Buddy List
 
cannedfool
Imba Community Member
Imba Community Member


Joined: 07 July 2003
Location: United Kingdom
Posts: 522
Posted: 22 September 2006 at 10:57am | IP Logged  

a list of numbers

+ative ones with a month field being ones before this month

0 = this month

-ative ones with a month field being ones after this month

so

-2 | nov 06

-1 | oct 06

0  | sept 06

1 | Aug 06

2 | jul 06

 

but i need to do it upto 60 each way

Back to Top View cannedfool's Profile Search for other posts by cannedfool Send Private Message Add to Buddy List
 
TheGouldFish
Honourary Member
Honourary Member
Avatar
The Mapper

Joined: 05 June 2003
Location: Scotland
Posts: 3456
Posted: 22 September 2006 at 11:43am | IP Logged  

So you are wanting to proudce a list of of dates and how many months ago that date was.

something like this
select ((TO_CHAR(INSTALLED,'YYYY') - TO_CHAR(sysdate,'YYYY')) * 12 + (TO_CHAR(INSTALLED,'MM') - TO_CHAR(sysdate,'MM'))) as months ,INSTALLED from BSBBROADBANDROUTER

give me an output of :

-2     06/07/2006 11:46:45
-2     13/07/2006 11:37:14
-2     14/07/2006 10:24:43
-2     27/07/2006 10:30:01
0     22/09/2006 10:10:16


You should see some of the SQL i've been putting together.

Edited by TheGouldFish on 22 September 2006 at 11:44am


__________________
TheGouldFish
=============
Fear the Fish
Back to Top View TheGouldFish's Profile Search for other posts by TheGouldFish Visit TheGouldFish's Homepage Send Private Message Add to Buddy List
 
cannedfool
Imba Community Member
Imba Community Member


Joined: 07 July 2003
Location: United Kingdom
Posts: 522
Posted: 22 September 2006 at 2:25pm | IP Logged  

cheers gould but still no cigar lol..

i want to be able to create a list of numbers -60 to + 60 then in another colum i want from 0 being this month a list of months increasing as the numbers go minus and decreasing the month as the numbers increase

Back to Top View cannedfool's Profile Search for other posts by cannedfool Send Private Message Add to Buddy List
 
TheGouldFish
Honourary Member
Honourary Member
Avatar
The Mapper

Joined: 05 June 2003
Location: Scotland
Posts: 3456
Posted: 22 September 2006 at 3:59pm | IP Logged  

Hmmmmmm not 100% sure what it is your trying to do any more.




__________________
TheGouldFish
=============
Fear the Fish
Back to Top View TheGouldFish's Profile Search for other posts by TheGouldFish Visit TheGouldFish's Homepage Send Private Message Add to Buddy List
 
Mojo Jojo
Moderatus
Moderatus
Avatar
Sir Sleeps Alot

Joined: 14 November 2002
Location: Scotland
Posts: 1916
Posted: 22 September 2006 at 4:29pm | IP Logged  

lol, he wants to print out a list of dates: i.e. from this month, going 60 months in the future, and 60 months in the past, and then next to each date have the number corresponding to how many months off the current month it is:

...
-3   June 2006
-2   Jul 2006
-1   Aug 2006
0   Sept 2006 - This month
1   Oct 2006
2   Nov 2006
3   Dec 2006
...

Have you looked into using ROLLUP instead of CUBE?

__________________
The two most common elements in the universe are Hydrogen and stupidity.

Back to Top View Mojo Jojo's Profile Search for other posts by Mojo Jojo Send Private Message Add to Buddy List
 
cannedfool
Imba Community Member
Imba Community Member


Joined: 07 July 2003
Location: United Kingdom
Posts: 522
Posted: 22 September 2006 at 7:19pm | IP Logged  

both only valid in 8.1 i think
Back to Top View cannedfool's Profile Search for other posts by cannedfool Send Private Message Add to Buddy List
 

Sorry, you can NOT post a reply.
This topic is closed.

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 1.2813 seconds.

Sponsored by Beatnik Games