Help requested with a subquery Analytics
I use Oracle 10 and it is necessary to obtain the necessary number of people for a particular job. The data are broken down by task and each task has a job and the amount of people needed. The assumption is that where the same business exists on more than one task that it is the same people, so normally I could take the Max by profession and their maximum amount. This is not possible as a subquery, so I try to use analytics and it doesn't work any better. Here some samples:Task ID Craft people
10 1 MECH
20 FORKTRAN 1
OPENG 30 3
DIVE 40 4
50 WORK 1
60 2 MECH
70 1 LABOR
80 3 OPENG
DIVE 90 4
The table has millions of records, and it is not possible to view online. How can I have a subquery unique coorelated who turn 11 in this example?
The max for the latter are:
Diving 4, ForkTran 1, labor 1, Mech 2, Openg 3 = 11
Any help would be greatly appreciated.
Have you tried
Select Job,
Description,
(Select Sum(Max(Quantity)) From TaskData Where Job = Jobs.Job Group by Craft) as Quantity
From Jobs
;
?
It seems to work for me (11.2.0.2). I get
JOB DESCRIPTION QUANTITY
---- ------------------ ----------------------
JOB1 Redo the site 11
JOB2 Clean up the site 10
JOB3 Move things around 3.7
JOB4 Clean the lake 5
The section of aggregate SQL Reference functions explains how tag aggregate functions are evaluated. It should work in 10g more.
Kind regards
Bob
Published by: BobLilly on March 12, 2012 15:13
Tags: Database
Similar Questions
-
Help requested with problem of Validation of the W3C
In order to position the text from a database with precision in a cell, that I used:
< span class = "cont_layer" >
<? PHP echo $row_restSelect ["cel_blb"]; Insert the details of dbase? >
</span >However, I use tinyMCE to the entry for the MYSQL database interface and tinyMCE put in tags like < p > in all directions, so the output looks like this:
< span class = "cont_layer" > < p > Some text. < br / > a text more. < br / > < br / > and some more text. < /p > < / span >
It works very well in practice, but I noticed that the W3C Validation rejects the structure with:
"document type does not allow element 'p' here; a lack of "object", "applet", "map", "iframe", "button", "ins", "del" start tag"
I use XHTML Transitional.
Is there a way to get around this, or should I stop being so anal about validation?A is for items online and cannot contain elements of type block, as paragraphs. Replace your by a
and everything will be hunky-dory. -
Hi all
I have nightmares with a request, I can not just think. I hope someone can help me with this.
There are 4 tables
customers-> (PK) Cust_id, cust_name, cust_lname...
Invoice-> Invoice_number (PK), cust_id (FK) invoice_date
Invoice_line-> Invoice_number (FK), line_units, line_price and Prod_code (FK)
Product-> Prod_code,... etc.
And I need to do a query that shows me the name of the customer who has spent more money.
The money is obtained as (line_price * line_units), but there are several lines of Invoice_line in each invoice
So Ive done this so far, but I don't know how to extract the max value and bound on behalf of the customer so I can show just the client name (cust_fname) and family name (cust_lname).
Select i.cust_id, sum(line_price*line_units)
Join Invoice_Line Bill it I
on it .invoice_number = i.invoice_number
I.Cust_Id group;Hello
user12964841 wrote:
Im having this error, how can I manage?SQL > WITH got_cust_amt LIKE
() 2
3. Select i.cust_id
4, sum (line_price * line_units) AS cust_amt
5, RANK () OVER (ORDER BY sum (line_price * line_units))
6 AS r_num
7 of Invoice_Line it
8 join Bill I on il.invoice_number = i.Invoice_Number
Group 9 by i.Cust_Id
10)
11. SELECT c.cust_id
12, c.cust_name
13, c.cust_lname
14, a.cust_amt
15. FROM customers c
Has 16 JOIN got_gust_amt ON c.cust_id = a.cust_id
17 WHERE a.r_num = 1
18;
JOIN got_gust_amt a ON c.cust_id = a.cust_id
*
ERROR on line 16:
ORA-00942: table or view does not existThe error message points to line 16. What's line 16?
JOIN got_gust_amt a ON c.cust_id = a.cust_id
Do you see something fishy there, particularly with regard to a table name? It corresponds to the name given in the WITH clause?
WITH got_cust_amt AS
Sorry, I spelled wrong. If you want anything tested on this forum, poster CREATE TABLE and INSERT statements for some examples of data.
-
I have three tables listed below
FORMAT - Columns are format_id, format_desc
VIDEO_FORMAT - areVIDEO_FORMAT_ID of columns, COST VIDEO_ID, FORMAT_ID,
RENTAL - Coulmns are RENTAL_ID, DATE_OUT, DATE_DUE, DATE_IN, DELIVERY_STATUS, LATE_FEE, CUSTOMER_ID, VIDEO_FORMAT_ID
I need to find the customer list id, format description and cost of the video format for customers who have rented a video.
I wrote the request
Select rental r format f, video_format, r.customer_id, f.format_desc, vf.cost vf where f.format_id in (select video_format format_id) and r.video_format_id = vf.video_format_id
This isn't to get accurate results. Help, please.Would know what kind of results you get, but I think that I can see.
Try:
Select r.customer_id, f.format_desc, vf.cost
rental r, f format, video_format vf
where vf.format_id = f.format_id
and r.video_format_id = vf.video_format_idCan't be sure without a little more information so that will set you. But I do not know why you went with trying to get a relationship using an IN with a subquery. It will be useful.
-
Could someone help me with a HP mini 1000 bios password
Can someone help me with a HP mini 1000 bios password
I can not remember than ever the value one, but it pop out out of blue.
The S/N is less to:
CNU926623M
I'm pretty much here sitting ducks.
Any help will be greatly appreciated.
Thank you very much.
Hello
Try the code below
e9lo7gg7f4
Use the posted above unlock code to access the BIOS
Disable all passwords that are enabled
If current password request - type the unlock code
New password, simply press the ENTER key
Repeat the same thing to check the password column.Then exit the BIOS saving & exit option to save the changes.
-
Help me with this error report... :(
This is my request
SELECT VENDOR_ID, $VENDOR_NAME, CREATION_DATE AP_SUPPLIERS WHERE VENDOR_ID BETWEEN: P_FROM AND: P_TO
& P_WHERE ORDER BY VENDOR_ID
& P_WHERE EAST LEXICALE parameter that will b called trigger report parameter...
function boolean return AfterPForm is
Start
IF (: P_FROM IS NULL AND: P_TO IS NULL) THEN
: P_WHERE: =' ';
ON THE OTHER
: P_WHERE: =' WHERE BETWEEN VENDOR_ID: P_FROM AND: P_TO';
END IF;
return (true);
end;
the report is getting filled with success, but when I check the print review I get the error message: error ORA-00933...
Please help me with this,
_________________________________________________________________________________________________
Vinay Thakur
Use:
SELECT VENDOR_ID, $VENDOR_NAME, CREATION_DATE
OF AP_SUPPLIERS
& P_WHERE
ORDER BY VENDOR_ID
and:
function boolean return AfterPForm is
Start
IF (: P_FROM IS NULL OR : P_TO IS NULL) THEN
: P_WHERE: = ";
ON THE OTHER
: P_WHERE: = ' WHERE BETWEEN VENDOR_ID: P_FROM AND: P_TO';
END IF;
return (true);
end;
Kind regards
Zlatko
-
Send the POST request with BLOB content
Hello
I usually use the following structure to send the POST request with content of varchar2 and numbers
content := '{"Original File Name":"'||V_HOMEBANNER_1_EN_NAME(indx)||'"}'; url := 'https://api.appery.io/rest/1/db/Names'; req := utl_http.begin_request(url, 'POST',' HTTP/1.1'); UTL_HTTP.set_header(req, 'X-Appery-Database-Id', '5f2dac54b02cc6402dbe'); utl_http.set_header(req, 'content-type', 'application/json'); UTL_HTTP.set_header(req, 'X-Appery-Session-Token', sessionToken); utl_http.set_header(req, 'Content-Length', LENGTH(content)); utl_http.write_text(req, content); res := utl_http.get_response(req); BEGIN LOOP utl_http.read_line(res, buffer); END LOOP; utl_http.end_response(res); EXCEPTION WHEN utl_http.end_of_body THEN utl_http.end_response(res); END;
And it works very well. However, now I want to send/download (jpg image) files a blob in a MongoDB collection called "Files" (so url: = ttps://api.appery.io/rest/1/db/files). The guide of the collection is the next loop as a general advice:
curl -X POST \ -H "X-Appery-Database-Id: 5f2dac54b02cc6402dbe" \ -H "X-Appery-Session-Token: <session_token>" \ -H "Content-Type: <content_type>" \ --data-binary '<file_content>' \ https://api.appery.io/rest/1/db/files/<file_name>
But I couldn't translate this curvature in PL/SQL query. Specifically, the part (-given binary '< file_content >")
I have these BLOB files in an Oracle table, and they are stored with their names as follows:
File_name File_content PIC_1.jpg BLOB OBJECT PIC_2.jpg BLOB OBJECT PIC_3.jpg BLOB OBJECT My question, how to download these images in the target URL?
After a few hours I spent on it, I got it working. My solutions is inspired by this http://blog.optiosys.com/?p=246
Since you must send you no the (same) CLOB and BLOB files, you need just need to replace .write_text by .write_raw.
Here is my part of work for your reference:
content: = V_HOMEBANNER_1_EN (indx); -blob
file_name: = 'test.jpg ';
URL: = "https://api.appery.io/rest/1/db/files/": file_name;
Req: = utl_http.begin_request (url, 'POST', ' HTTP/1.1');
Utl_http.set_header (req, 'X-Appery-database - Id', '53fae4b02cc4021dbe');
Utl_http.set_header (req, 'X-Appery-Session-token', sessionToken);
Utl_http.set_header (req, "content-type', ' image/jpeg");
req_length: = DBMS_LOB.getlength (CONTENT);
DBMS_OUTPUT. Put_line (req_length);
-IF YOU LIMIT THE DATA UNDER 32KB MSG:
IF req_length<=>=>
THEN
Start
Utl_http.set_header (req, "Content-Length", req_length);
Utl_http.write_raw (req, content);
exception
while others then
DBMS_OUTPUT. Put_line (SQLERRM);
end;
-IF MSG DATA MORE THAN 32 KB
ELSIF req_length > 32767
THEN
BEGIN
DBMS_OUTPUT. Put_line (req_length);
Utl_http.set_header (req, "Transfer-Encoding", "Chunked");
While (offset<>
LOOP
DBMS_LOB. Read (content, amount, offset, buffer);
Utl_http.write_raw (req, buffer);
offset: = offset + amount;
END LOOP;
exception
while others then
DBMS_OUTPUT. Put_line (SQLERRM);
end;
END IF;
l_http_response: = UTL_HTTP.get_response (req);
Utl_http.READ_TEXT (l_http_response, response_body, 32767);
Utl_http.end_response (l_http_response);
I hope this helps. Good luck
-
Hi all
I'm kinda stuck with the call of mergetable with a subquery.
I manually track user changes in a table not versioned; When I try to merge changes from the user in 'live', I get the following error:
ORA-20077: insufficient privileges on the table with version ' SYSTEM. CLASS'
ORA-06512: at "WMSYS.LT", line 7191
ORA-06512: at line 2
the appeal of fusion is the following:
BEGIN
DBMS_WM. MergeTable ('WORK', 'class', WHERE = > 'id IN (select id changes)');
end;
/
As you can see, I am logged in as a user of DBMS_WM package test system
The 'class' table is versioned.
The 'changes' table is not versioned
ID is the primary key for the table 'class', but not for the table "changes".
When I change the where clause with some id = xx, the fusion is successful.
What a privilege can expect I'm connected like system?
I'm using Oracle 11 g R2.
Thanks for any help,
Kind regards
--
StéphaneHi Stephane,
Add the schema on the change tables. "id IN (select id from system.modifications). This should fix the error.
Kind regards
Ben -
Can anyone help please with Javascript. 2 small problems.
Hello. I created a dynamic PDF form with fields. I have 2 problems that I don't know that someone can help me with. (Someone I can email this PDF on request).
PROBLEM 1. In this form, I have a table (in fact I think that it is a form of sub) which has 3 buttons associated with it ('Add Row', 'Delete Row' and (line Clear').) A single button adds a new line. It works, but effectively, it duplicates the line (and all the fields/cells of text contained in the line) and this new line at the bottom of any existing lines. What I'm asking, is for this button (the button gets duplicated with the line) to place the new line immediately below the line where it is clicked. That is to say, imagine you open the document, complete line (at this stage it is only) and click on the button 'Add Row '. You now have 2 rows (large), while you complete the second row. Now, here's my problem, if you press the button "Add a line" on the first line, a new 3rd line is added at the bottom and not between line 1 and line 2.
Actually if you have dozens of lines filled and you need to insert a line of amendment, currently it is impossible without deleting all the lines to the point where you want to check/insert.
PROBLEM 2. In this line of alphanumeric text, the are two fields (called "Rate" and "Loading") where dollar amounts are entered. As the form is filled (lines can be generated dynamically and there fields filled out manually by the user) there may be potentially dozens of lines in a completed form and, as each line has several fields of alphanumeric text, one can imagine of forming columns once there is more than 1 line. At the end of the form, the totals are automatically calculated. I created a button to reset (clear) all amounts in these two specific areas (columns), but in all ranks. Unfortunately there is something wrong with my script syntax like this button does not. (I want this facility as the end of the form, which is a draft budget, I need to send two copies - one accountants with numbers and logistics and a second copy to another Department that I don't want to give the figures, so I need the key to clear the numbers without having to erase each cell individually).
Any help that anyone can give would be much appreciated.
Please send me an email to
[email protected] If you want I send you the file.
See you soon
Bradd
Send the form to
[email protected] and I will give it a go... include a reference back to this forum announcement.
Paul
-
Help me with SQL Query to retrieve data from a view
Hello Guru,
I need help in my sql query.
I use SQL TeraData.
I want an Oracle result in the following form-
Open tickets
Open months failure / Repair Service s/o improvement request Total general
2009-01-2 4 4 5 15
2009-02 1 0 2 3 6
2009-03 4 1 2 2 9
Grand Total 7 5 8 10 30
I wrote the query as where - TIME_PERIOD, RQST_TYPE_DM and DEMAND_SUMMARY_FCT are the points of view and I extract the data from the views only.
Select NVL (CA. TIME_PERIOD. PERIOD_CD, 'Total') THAT year.
COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% of Break' THEN 1 END) as BreakFix
COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'N/a', 1 END) by n/a
COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC as 'Improvement' THEN 1 END) accessories
COUNT (CASE WHEN CA. RQST_TYPE_DM. RQSTTYP_DESC Like '% Service' THEN 1 END) as ServiceRequests
COUNT (CA. RQST_TYPE_DM. RQSTTYP_DESC) AS grand_total
FROM CA. TIME_PERIOD, CA. RQST_TYPE_DM, CA. DEMAND_SUMMARY_FCT
WHERE (CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = CA. RQST_TYPE_DM. RQSTTYP_ID)
AND (CASE
WHEN CA. DEMAND_SUMMARY_FCT. MONTH_ID = CA. TIME_PERIOD. PERIOD_ID, 1
WHEN {fn concat ({fn concat (SUBSTR (CA. TIME_PERIOD. {(PERIOD_CD, 3, 4),'-')}, SUBSTR (CA. TIME_PERIOD. PERIOD_CD, 7, 2))} BETWEEN ' 2009-01' AND ' 2009-03' THEN 1
WHEN CA. DEMAND_SUMMARY_FCT. RQSTTYP_ID = '1' then 1
END) = 1
GROUP BY ROLLUP (CA. TIME_PERIOD. PERIOD_CD)
After executing the query, I get the following error:
3076: syntax Error: Data Type 'Time' does not match a defined Type name.
:( Kindly help me with this and let me know where I'm wrong... Please.Messages indicates something wrong with your data... It would seem that the data does not match your format mask.
Thus, the data or the format mask.
-
Sorry, I can't help you with HomeKit here.
I have a few devices HomeKit home, working with Siri on my iPhone.
On the Apple TV, I just received this message from Siri:
"Sorry, I can't help you with HomeKit here."
HomeKit is not supported by Siri on the new Apple TV?
N ° Homekit uses the ATV as a server control devices when there not home but is not currently configured to contol these devices of the distance of siri.
Use the HomeKit accessories compatible with your iPhone, iPad and iPod touch - Apple Support
-
The address bar where I can type in the Web addresses does not appear on my Mozilla, please help me with this... How to activate it?
Hi kdwis,
Going to try view > toolbars and activation of the Bar of Navigation and in the bookmarks toolbar.
Hope this helps!
-
Question
Sir please help me with my home page. When I put my Home Page about: welcome it gives an error saying invalid Url... Please tell Me how to fix it!Subject: House = without capital letters
-
NB100 help please with fan and graphics settings
Hi, I just bought the NB100 and have a few questions, I hope someone can help me with.
The fan icon goes grey or white according to the parameters by using FN and F6, but I can't feel any difference in the air around the grid on the right. It is on when the icon shows white or gray? Does really?
My second question is about the graphics settings. The intel power option that appears when the icon in the taskbar graphivs is double clicked seems to be disabled. There are automatic brightness sliders and energy saving, but none can be selected, how is it permits?
My last question is about the games. I tried a few alumni who were not graphic intensive, Deus Ex and the sins of a solar empire, but I had problems in the text boxes that require a response, and in the case of Deus Ex, they say that the graphics drivers are not compatible. Has anyone got Ant with games? I travel a lot and thinking, I want to have one or two other than playing cards installed etc.Thanks and regards, Brian
On my machine that F6 is to mute sound, F8 is for the cooling fan. Based on this fact the fan speed change.
I can't help with the power settings, like mine all seem to work OK and I can make changes.
Have you tried changing the settings through preferences/system/Power Management? -
Hello! Can someone help me with the address of repair service for Palm TX?
Hello! Can someone help me with the address of repair service for Palm TX?
Good luck and please, let us know here how it works for you. We like to know current resources, which can help to solve the problems of people with these older devices.
Maybe you are looking for
-
HP PAVILION ELITE E9280T D: CTO need new recovery disc
I have a pair of old HP Pavillion E9280T desktop systems. I have recently installed a new hard disks on the two (both are identical machines, ordered that a pair of HP). I also have a two sets of recovery disks that I made when the systems are new,
-
I mean, I'm using the same version of Firefox on a similar to cpmputer, and I do not have the "new tab" aviable. I know there are other ways to open a new tab, but really I preffer it. I tried everything, but I'm stuck. Help appreciated. Thank you.
-
I got an error in the driver OR-SCOPE (version 4.1.3), using the NOR-5122 digitizer. The error is died in the niScope_SendSoftwareTriggerEdge function. The relevant sequence of commands that I send is: Secret = niScope_Abort (SessionID); Secret = niS
-
The error code automatic updates - Win XP Pro SP3 - 126 and 8007041 D
I just got rid of a trojan/virus. I'm clean now. But WU has been broken in this clean-up operation. Here's what I've done so far: I'm in Services.msc try to start the automatic updates service. It returns an error code 126 - the specified module
-
After several relocations I still see HP\HP LaserJet 200 color MFP M276\Help_Learn\Help.exe and clicking on the icon I can see (by the Task Manager) running. Nothing visible on the screen?