Need help with loading MySQL results into a query
Hello, I need some help figuring out why my tree component
isn't being populated with my MySQL results.
I have a table of categories:
ParentID - CategoryID - Name
Every top-level category has a ParentID of 0 (zero). I'm
using php and a recursive function to build an array of nested
results, then passing those results back to Flex, making those
results a new ArrayCollection, then assigning that to the
dataProvider of the tree.
Result: my tree component is blank
Suspicion: it has to be a way with how my array is being
formed in PHP. If I play around with how it is formed I can get
some odd results in the tree, so I know it's not a problem with the
data being passed back to Flex.
I am attaching the PHP code used to form the array, and the
output of the array being created
Why not just build xml and send it back? Xml is hierarchical
by nature.
However, if you want to stick with the nested ACs then are
you using a labelFunction() with your tree? The node values are in
different properties, so you can't just set labelField.
Tracy
Similar Messages
-
Need help with loading child .swf into parent .swf
Hello,
I am having trouble with an external .swf that isbeing loaded
into the master.swf. All of the files loads perfectly. However the
.swf that has the contact form movieclip in it will not work. The
combobox does that display any of the items listed and the form is
not being sent to the server. Can anyone give me a hand with
this?can you post your code
-
Need help with turning multiple rows into a single row
Hello.
I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
My situation:
I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
select jiraissue.id, pkey, reporter, summary
,changegroup.created change_dt
,dbms_lob.substr(changeitem.newstring,15,1) change_type
,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
from jiraissue
,changeitem, changegroup
,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
where jiraissue.project = 10110
and jiraissue.issuetype = 51
and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
and phaseinfo.issue = jiraissue.id
and changeitem.groupid = changegroup.id
and changegroup.issueid = jiraissue.id
order by jiraissue.id,change_dt
Results:
1 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 9:30:38 AM Open 1
2 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 11:37:02 AM Testing 2
3 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-06-08 9:14:52 AM Closed 3
4 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:37 AM Open 4
5 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:42 AM Open 5
6 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:50 AM Testing 6
7 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:53 AM Closed 7
8 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-10-03 10:26:21 AM Open 1
9 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-11-17 9:39:39 AM Testing 2
10 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2011-02-02 6:18:02 AM Closed 3
11 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2008-09-29 2:44:54 PM Open 1
12 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2010-05-29 4:47:37 PM Blocked 2
13 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:14:57 AM Open 3
14 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:32 AM Testing 4
15 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:47 AM Closed 5Hi,
Welcome to the forum!
StblJmpr wrote:
... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
CREATE TABLE changegroup
( issueid NUMBER
, created DATE
, id NUMBER
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'), 30);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
CREATE TABLE changeitem
( groupid NUMBER
, newstring VARCHAR2 (10)
INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
ISSUEID HISTORY
21191 Open (0) >> Testing (692) >> Closed
23234 Open (45) >> Testing (807) >> Closed
23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
"The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
The database is 10.2.0.4That's very important. Always post your version, like you did.
Here's one way to get those results from that data:
WITH got_order_row AS
SELECT cg.issueid
, LEAD (cg.created) OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
- cg.created AS days_in_stage
, ROW_NUMBER () OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
) AS order_row
, ci.newstring AS change_type
FROM changegroup cg
JOIN changeitem ci ON cg.id = ci.groupid
WHERE ci.newstring IN ( 'Blocked'
, 'Closed'
, 'Testing'
, 'Open'
-- AND ... -- any other filtering goes here
SELECT issueid
, SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
WHEN CONNECT_BY_ISLEAF = 0
THEN ' ('
|| ROUND (days_in_stage)
|| ')'
END
, ' >> '
, 5
) AS history
FROM got_order_row
WHERE CONNECT_BY_ISLEAF = 1
START WITH order_row = 1
CONNECT BY order_row = PRIOR order_row + 1
AND issueid = PRIOR issueid
AND PRIOR change_type != 'Closed'
ORDER BY issueid
;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary. -
Need help with load balancing and DNS proxy
Hi,
I need help on how to configure my router so it will work with my DNS proxy and load balancing.
I have a Linksys LRT224 router. I have two broadband connections from two separate ISPs,500Mbps each (WAN1 & WAN2). WAN1 has a static IP and WAN2 is dynamic assigned. I use Unlocator (www.unlocator.com) so I can access geographically restricted sites (Pandora, Netflix, etc.).
The problem I have is that unlocator registers only one IP address (WAN1 address) and since I am doing load balancing I have no way of knowing if the DNS request will go through the registered IP (WAN1) or through the other (WAN2). I am not an expert in routing or networking but I'm guessing I have a way of configuring the router so all the DNS requests go out through WAN1, right?
In the router's Dual WAN config page there is a section for Protocol Binding. I tried to configure but only managed to screw up the internet at home. I used:
DNS[UDP/53-53]->192.168.1.1-192.168.1.254(0.0.0.0-0.0.0.0)WAN2
Any help or suggestions are appreciated.
AlexGood solution though. That's probably the only way you could do true Load Balancing anyway.
Please remember to Kudo those that help you.
Linksys
Communities Technical Support -
Need help with load balancing and DNS proxy -Repost
Hi,
I need help on how to configure my router so it will work with my DNS proxy and load balancing.
I have a Linksys LRT224 router. I have two broadband connections from two separate ISPs,500Mbps each (WAN1 & WAN2). WAN1 has a static IP and WAN2 is dynamic assigned. I use Unlocator (www.unlocator.com) so I can access geographically restricted sites (Pandora, Netflix, etc.).
The problem I have is that unlocator registers only one IP address (WAN1 address) and since I am doing load balancing I have no way of knowing if the DNS request will go through the registered IP (WAN1) or through the other (WAN2). I am not an expert in routing or networking but I'm guessing I have a way of configuring the router so all the DNS requests go out through WAN1, right?
In the router's Dual WAN config page there is a section for Protocol Binding. I tried to configure but only managed to screw up the internet at home. I used:
DNS[UDP/53-53]->192.168.1.1-192.168.1.254(0.0.0.0-0.0.0.0)WAN2
Any help or suggestions are appreciated.
AlexGood solution though. That's probably the only way you could do true Load Balancing anyway.
Please remember to Kudo those that help you.
Linksys
Communities Technical Support -
[10g] Need help with order by clause in hierarchical query
I have the following sample data:
CREATE TABLE bill_test1
( parent_part CHAR(25)
, child_part CHAR(25)
, line_nbr NUMBER(5)
, qty_per NUMBER(9,5)
INSERT INTO bill_test1 VALUES ('ABC-1','ABC-10',100,1);
INSERT INTO bill_test1 VALUES ('ABC-1','ABC-20',200,2);
INSERT INTO bill_test1 VALUES ('ABC-1','ABC-30',300,3);
INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-1',401,10);
INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-2',402,5);
INSERT INTO bill_test1 VALUES ('ABC-10','ABC-155',100,2);
INSERT INTO bill_test1 VALUES ('ABC-10','HARDWARE-1',200,1);
INSERT INTO bill_test1 VALUES ('ABC-155','RAW-2',100,4.8);
INSERT INTO bill_test1 VALUES ('ABC-155','HARDWARE-3',200,3);
INSERT INTO bill_test1 VALUES ('ABC-20','RAW-1',100,10.2);
INSERT INTO bill_test1 VALUES ('ABC-30','RAW-3',100,3);And the query below gives me exactly what I want, in the order I want it. However, I am wondering if there is a way to get this order without creating the SEQ column, since I don't need it in my results
SELECT part_nbr
, parent_part
, child_part
FROM (
SELECT CONNECT_BY_ROOT b.parent_part AS part_nbr
, b.parent_part
, b.child_part
, SYS_CONNECT_BY_PATH(b.line_nbr,' ') AS seq
FROM bill_test1 b
, dual
CONNECT BY parent_part = PRIOR child_part
WHERE part_nbr = 'ABC-1'
ORDER BY seq
Results of above query, except with SEQ included in SELECT (just to show what I'm sorting off of):
PART_NBR PARENT_PART CHILD_PART SEQ
ABC-1 ABC-1 ABC-10 100
ABC-1 ABC-10 ABC-155 100 100
ABC-1 ABC-155 RAW-2 100 100 100
ABC-1 ABC-155 HARDWARE-3 100 100 200
ABC-1 ABC-10 HARDWARE-1 100 200
ABC-1 ABC-1 ABC-20 200
ABC-1 ABC-20 RAW-1 200 100
ABC-1 ABC-1 ABC-30 300
ABC-1 ABC-30 RAW-3 300 100
ABC-1 ABC-1 HARDWARE-1 401
ABC-1 ABC-1 HARDWARE-2 402Hi,
As long as there's only one root, you can say ORDER SIBLINGS BY, but you can't do that in a sub-query (well, you can, but usually there's no point in doing it in a sub-query). If the CONNECT BY is being done in a sub-query, there is no guarantee that the main query will preserve the hierarchical order that the sub-query provides.
The query you posted doesn't require a suib-query, so you can say:
SELECT CONNECT_BY_ROOT b.parent_part AS part_nbr
, b.parent_part
, b.child_part
--, SYS_CONNECT_BY_PATH(b.line_nbr,' ') AS seq
FROM bill_test1 b
WHERE CONNECT_BY_ROOT b.parent_part = 'ABC-1'
CONNECT BY parent_part = PRIOR child_part
ORDER SIBLINGS BY b.line_nbr
;I said the query you posted doesn't require a sub-query. It also doesn't require dual, so I suspect what you posted is a simplification of what you're really doing, and that may need a sub-query. In particular, if you intend to GROUP BY part_nbr, then you need the sub-query. We can repeat the CONNECT_BY_ROOT expression in the WHERE clause (or, now that I think about it, use a START WITH clause instead of WHERE), but, for some reason, we can't use CONNECT_BY_ROOT in a GROUP BY clause; we need to compute CONNECT_BY_ROOT in a sub-query, give it a name (like part_nbr), and GROUP BY that column in a super-query.
This assumes that there is only one root node. ORDER SIBLINGS BY means just that: children of a common parent will appear in order, but the root nodes, who have no parents, will not necessarily be in order.
Here's what I meant by using START WITH instead of WHERE:
SELECT CONNECT_BY_ROOT b.parent_part AS part_nbr
, b.parent_part
, b.child_part
--, SYS_CONNECT_BY_PATH(b.line_nbr,' ') AS seq
FROM bill_test1 b
START WITH b.parent_part = 'ABC-1'
CONNECT BY parent_part = PRIOR child_part
ORDER SIBLINGS BY b.line_nbr
;This should be much more efficient, because it narrows down the results before you waste time getting their descendants.
Using a START WITH clause here is analagous to me sending you an e-mail, saying "Come to a meeting a my office at 3:00."
Using a WHERE clause here is analagous to me sending an e-mail to everyone in the company, saying "Come to a meeting a my office at 3:00", and then, as people get here, telling everyone except you that they can go back.
ORDER SIBLINGS BY was introduced in Oracle 9.
Edited by: Frank Kulash on Dec 9, 2010 2:39 PM
Added version with START WITH clause -
Need help with loading Windows 7 onto Macbook Pro - Bootcamp and parallels
Hi,
I have a windows PC and changing over to a Mac. I purchased today Parallels and Microsoft Office for Mac in order to use them on the MacBook.
Also please note - I need to use Bootcamp for some programs that I need to use - and then also be able to use parallels.
Where I am up to at the moment is - since there is no disc drive on the laptop where I can insert the disc - I have gone onto my PC and downloaded the Windows 7 usb/dvd download tool setup - however I dont know where I find the ISO file for Windows 7? So if someone could help me with that.
Alternatively - can someone please let me know if I can just pay and download Window 7 for Mac - and then run it through boot camp etc. If someone can please give me some advice on this - and also a handy step by step guide on how to achieve it.
Thank you so much in advance for your help!!!! I really appreciate it!
KThanks Clinton - When I went into Apple store today, I told him about the programs my husband needs to use for a CBUS course. The guy there said his room mate has done the same thing and cannot use parallels for the programs they need to run (it doesnt seem to work properly) so he is using boot camp to run them and it works fine. So I am wanting to run Boot camp first and then once the course is finished run everything through parallels.
So I have gone into Boot Camp - and because there is no Disc drive I cannot insert the disc - so I have gone back onto the PC to put windows onto a USB to then use with Bootcamp. I just cannot find the ISO file path for Windows.
I hope this all makes sense!
I am thinking I maybe i will buy the windows ISO file instead of trying to hunt it down on the PC. Do you think this is the best way to do it? -
Need help with loading master data from R/3 to BI 7.0.
Hi,
First i thank everybody who took efforts to answer for my posting, i really am learning this new version with your helps. I really appreciate it.
Could any one help me with a step by step process to load master data from R/3 to BI 7.0. Please don't send help.sap.com.
will assign points .
With Thanks,
Ranjani RHi,
Thanks for the answers. I tried loading it yesterday, i had lot of confusions.
What should i do to load a master data from a R/3 to BI7.0.
1. Created a Info object named (EKKO_mas) with some attributes (ernam, ekorg, lifnr).
2. Go to info provider and right clicked on info area and selected insert char as data target. (Please correct if i am wrong).
3. Login to R/3, go to sbiw generic data source created one with a view/table as EKKO and map the application compound and select the needed fields by checking the checkbox. (please correct if wrong).
4. Go to source system tab and replicate data source. ( Please correct if i am wrong)
Then what should i do.
guessing steps:
4. Create a Data source, in BI 7.0 . In that as i am not using flat file, should i select "application server" instead of "local workstation" . In field tab i specified all the fields given in Info object. ( Will there be anything else i should do or change in this tab)
5. Load data in PSA. ( will the data from R/3 i selected loaded in PSA without any problem)
6. Create transformation , save and activate.
7. Create DTP save and activate , click execute.
By doing the above given step will i be able to load the master data from R/3 to BI 7.0 data target (IO) . Please help me if something is wrong with my steps.
Thanks.
RR.
*will assign points. -
Need help with document that turned into alias for Application
I'm trying to help my dad with a problem, not sure exactly what he did, but he had a page document in a documents folder on his desktop. He moved it into a *files folder* on his desktop. Somehow the document seems to have been turned into an alias for for his application folder. When I click on the file name, the document doesn't open, it opens up the Application folder.
I'm VERY new to Mac.
Any help would be appreciated. Thank you.This should answer the question:
http://support.apple.com/kb/TA26514 -
Need help with loading files from Sony cam!
How can I import files from a Sony DCR-SR100 camera into FCP 6.0.1?
Will it work with the Log&Transfer function?
Camerainfo here:
http://www.sony.no/view/ShowProduct.action?product=DCR-SR100E&site=odwnoNO&pageType=Overview&imageType=Main&category=SDHHard+DiskDriveFCP does not currently support HDD camcorders. For a more detailed explanation, check out this:
http://discussions.apple.com/thread.jspa?messageID=4719805�
The only solution I can think of that might (might) work is to import using iMovie 08, which claims to support certain HDD cams, and transfer into FCP. -
Need help with loading images in executable Jar
Hi,
I've developed an application using netbeans that needs to load and display images.
I use netbeans Clean and Build function to create an executable Jar file. When I run the executable Jar file it runs fine but when I come to a section of the application that needs images it freezes and can't load the images.
When I then return to netbeans the part of the program that did successfully run before Clean and Build doesn't work anymore and I get an error message saying Uncaught error fetching image:
I use,
URL url = getClass().getResource("images/image1.png");
Image image1 = Toolkit.getDefaultToolkit().getImage(url);to load an image.
Can someone tell me why, when I clean and build my project to create a JAR, my images fail to load.
Should I be storing the images in a specific folder or something??
ThanksI've opened the JAR using winzip and, for some reason, the JAR hasn't preserved my file structure. So, when I try to look for an image as follows:
URL url = getClass().getResource("images/file1.png");
Image img= Toolkit.getDefaultToolkit().getImage(url);The folder doesn't exist and so it can't find the image.
Can someone tell me how to keep my file structure when I create the JAR or an alternative way to find the images within the JAR file.
Cheers -
Hi, Is it possible to import a flash/swf file in to
fireworks... If so... how..????
Thank You for Your Help...can you post your code
-
Need help with loading XML file
Hello,
I have been browsing the web/forums for an example on how to do this for a few days now. I managed to get this working in Flash Pro quite easily but I think I am missing something when I want to do the same thing in Flex.
Basically I want to load an XML file and then set the text values of 5 labels equal to the data in the XML file.
So I a button created in MXML and have set the click event as follows:
click="dsSetup(event)"
I have also declared the following:
public var myRequest:URLRequest = new URLRequest("assets/myFile.xml"); //folder located under src in project
public var myLoader:URLLoader = new URLLoader();
public var myXML:XML;
My function that loads is as follows:
public function dsSetup(event:MouseEvent):void
trace ("dsSetup");
myXML = new XML (myLoader.data);
h3.text = myXML.source.itemA;
h4.text = myXML.source.itemB;
h5.text = myXML.source.itemC;
h7.text = myXML.source.itemD;
h8.text = myXML.source.itemE;
currentState = 'MainMenu';
myLoader.addEventListener(Event.COMPLETE, dsSetup); // I think this line is now redundant as I have set it in the MXML
myLoader.load(myRequest);
This is the way I did it in Flash and it worked ok but I must be missing something in when it comes to Flex.
Can someone explain or point me to a good tutorial that shows how to load XML in Flex?
The ones I found seem to have about 50 lines of code just to load a file and add in way to much complexity for a beginner.
Many ThanksI would suggest to save the loaded data in a Bindable variable and then to bind the text-properties to that:
[Bindable]
var myXML:XML;
public function dsSetup(event:MouseEvent):void
myXML = new XML (myLoader.data);
currentState = 'MainMenu';
<s:Label text="{myXML.source.itemA}"/> -
Need help with detail by hour in SQL query
Hello all,
I am using the following query to track the usage on a circuit and I have the detail by day, but now they are asking for hourly usage from 0900 to 1200 on these days. Any ideas how I can append to include hour in my detail?
select 'Report Name Here' as Circuit,'Usage' as Measurement,
MONTH(interfacetraffic.datetime) as month, year(interfacetraffic.datetime) as year, day(interfacetraffic.datetime) as day,
'' as Mo_yr,
interfaces.inbandwidth as bandwidth,
'' as adjustedbandwidth,
max (interfacetraffic.in_maxbps ) as max_in,
max (interfacetraffic.out_maxbps) as max_out,
avg(interfacetraffic.in_maxbps ) as avg_in,
avg(interfacetraffic.out_maxbps) as avg_out,
max(case (interfacetraffic.in_maxbps ) when 0 then 0 else(interfacetraffic.in_maxbps )/interfaces.inbandwidth *100 end) as 'max_in_%',
max(case ( interfacetraffic.out_maxbps) when 0 then 0 else( interfacetraffic.out_maxbps )/interfaces.outbandwidth *100 end) as 'max_out_%',
avg(case (interfacetraffic.in_maxbps ) when 0 then 0 else(interfacetraffic.in_maxbps )/interfaces.inbandwidth *100 end) as 'avg_in_%',
avg(case ( interfacetraffic.out_maxbps) when 0 then 0 else( interfacetraffic.out_maxbps )/interfaces.outbandwidth *100 end) as 'avg_out_%',
nodes.location as location,nodes.sysname as sysname,nodes.timezone,interfaces.interfaceid as interfaceid,nodes.nodeid as nodeid,interfaces.fullname as fullname
FROM
(Nodes INNER JOIN Interfaces ON (Nodes.NodeID = Interfaces.NodeID))
INNER JOIN InterfaceTraffic ON (Interfaces.InterfaceID = InterfaceTraffic.InterfaceID AND InterfaceTraffic.NodeID = Nodes.NodeID)
where InterfaceTraffic.DateTime > GETDATE() -180
and interfaces.InterfaceID = '31072'
and month(interfacetraffic.datetime) = 1
and year(interfacetraffic.datetime) = 2015
--and DATEPART(hh,interfacetraffic.datetime) in ('09','10','11','12','13','14','15','16','17','18','19')
group by interfaces.inbandwidth, year(interfacetraffic.datetime),
MONTH(interfacetraffic.datetime) ,nodes.location ,nodes.sysname,interfaces.inbandwidth,nodes.timezone ,interfaces.interfaceid,nodes.nodeid,interfaces.fullname, day(interfacetraffic.datetime)
--DAY(InterfaceTraffic.DateTime)select 'Report name here' as Circuit, 'Usage' as Measurement,
month(...) as month, year(...) as year, day(...) as day, datepart(hour, ...) as hour,
from ...
group by month(...), year(...), day(...), datepart(hour, ...), ...
Note - have you considered just having a single column for the date as opposed to 3 separate columns? And for efficiency, change your where clause from
where InterfaceTraffic.DateTime > GETDATE() -180
and interfaces.InterfaceID = '31072'
and month(interfacetraffic.datetime) = 1
and year(interfacetraffic.datetime) = 2015
to
where interfaces.InterfaceID = '31072'
and interfacetraffic.datetime >= '20150101' and interfacetraffic.datetime < '20150201'
and datepart(hour, ...) between 9 and 19
That first part involving "getdate() - 180" does nothing useful when you only want values from January of this year. -
Subquery results need help with output
Requirements:
There is request to dump every days data from one table into text file.
Tables:INSPECTION_RESULTS
NJAS
Primary Key: RES_SYS_NO
Parent table: INSPECTION_RESULTS
Child table: NJAS
Purpose:
1. obtain output results for the MIN and MAX RES_SYS_NO from INSPECTION_RESULTS table for yesterdays date.
2. Create comma delimited file for following columns using above table data output.
Script thus far:
SELECT NJA_RES_SYS_NO||','||NJA_TEST_REC_NO||','||NJA_LIC_ST_ID||','||NJA_ETS_ID||','||NJA_SW_VER||','||NJA_TECH_ID||','||NJA_VIN||','||NJA_LIC_NO||','
||NJA_LIC_JUR||','||NJA_LIC_SRC||','||NJA_MODEL_YR||','||NJA_MAKE||','||NJA_MODEL||','||NJA_VHCL_TYPE||','||NJA_BODY_STYLE||','||NJA_CERT_CLASS||','||
NJA_GVWR||','||NJA_ASM_ETW||','||NJA_ETW_SRC||','||NJA_NO_OF_CYL||','||NJA_ENG_SIZE||','||NJA_TRANS_TYPE||','||NJA_DUAL_EXH||','||NJA_FUEL_CD||','
|| NJA_VID_SYS_NO||','|| NJA_VRT_REC_NO||','|| NJA_ARMSTDS_REC_NO||','|| NJA_RSN_F_N_TESTABLE||','|| NJA_DYNO_TESTABLE||','||
NJA_CURR_ODO_RDNG||','|| NJA_PREV_ODO_RDNG||','|| NJA_PREV_TEST_DT||','|| NJA_TEST_TYPE||','||
NJA_TEST_START_DT||','|| NJA_TEST_END_TIME||','|| NJA_EMISS_TEST_TYPE||','|| NJA_TEST_SEQ_NO||','
||NJA_LOW_MILE_EXEMP||','||NJA_TIRE_DRY||','|| NJA_REL_HUMID||','|| NJA_AMB_TEMP||','||NJA_BAR_PRESS||','|| NJA_HCF||','||
NJA_GAS_CAP_ADAP_AVL||','|| NJA_GAS_CAP_REPL||','|| NJA_OVERALL_GAS_CAP_RES
FROM NJAS
WHERE NJA_RES_SYS_NO IN (SELECT MIN(NJA_RES_SYS_NO) FROM INSPECTION_RESULTS WHERE NJA_RES_SYS_NO IN
(SELECT MAX(NJA_RES_SYS_NO) FROM INSPECTION_RESULTS, (SELECT SYSDATE-1 FROM DUAL))
It works but not sure if I am getting accurate results. Can anyone help me fine tune this subquery script? Thanks!
ScottDuplicate post
See my answer in your other posting here Re: need help with script
Maybe you are looking for
-
if Firefox is already running and click on any link in Word, Excel, Outlook, etc. A message box pops up and I have to hit OK to close it. "firefox is already running, but not reponding. To open a new window, you must first close the existing firefox
-
Started to Erase External HD, Is No Longer Recognized.
I know this was a crazy oversight on my part, but in case there is someone out there that can help, here's the scenario: An external hard drive, totally reformatted to store files in MS-DOS, as I am sharing work files with a Windows computer. Trying
-
Dear all, I am trying to change the Price control of a material from V to S. It is showing me a system message as follows: Price control cannot be changed (cost component split exists) Message no. M3160 Diagnosis Costing is active and has already bee
-
Cs6 and Premiere stop working suddenly
I have cs6 in win8.1 64bit. My cs6 was working fine. Now premiere wont open any hd material. What is wrong? Can I install only Premiere or do i have to deactivate master collection and install all again?
-
Smart groups in iCloud not working!?
smart groups are great but totally useless if they won't appear on your iphones / iPad , ... any hints / workarounds out there?