SQL to group by a column, but a group of field date
HelloI have a table that contains three columns.
Col1 error code
Col2 Date
COL3 error message
I have created a pie chart in the APEX and need to have two values in select it only. However, I would like to generate the pie chart that shows the number of errors grouped by error on a monthly basis.
Something like
Select col1, count (*) table
Group of col1.
Now, this will give you the total of errors in the table grouped by error code without taking into account of the period. No idea, how can I combine the error codes say every month. However, I can't add the date in the select as the pie chart does not accept that.
Thank you
Sun
Hi, the Sun,
If it is a problem of Apex, then post in the forum of the Apex
Oracle Application Express (APEX)
To view this information in a graphical pie, it seems that you need a separate pie chart for each month, or maybe a pie chart are for each error code.
Bar graphs and line grapsh are best for the output like what you describe.
Looks like you can get the data you want to look like this:
SELECT col1
, TRUNC (col2, 'MONTH') AS month
, COUNT (*) AS n
FROM table_x
GROUP BY col1
, TRUNC (col2, 'MONTH')
;
Now you must decide how you want to present it and (I assume) ask someone using Apex you do this forum.
Tags: Database
Similar Questions
-
Arrange the tiles in a column, but multiple lines
When you have the tiles on The start screen of Metro , you can set the group / block a tile only, but when you want to add the second tile to this group / block, you can put only horizontally (from left or right tile existed), in other words, you can add the column within that group, but you can put the new Tile vertically , under a tile already existence.
I want to define group / block of tiles with a single column, but multiple lines.For example, instead of this:xx xx xx xxxx xx xxto get this:xx x xx xxxx x xx xxScreenshot:Hi Mike b. II.
It's normal. You cannot have tiles in groups vertically. Now in your case, if you change the tiles to large tiles, they will stack vertically.
-
I want to get only year sysdate with my name of the defined column. but not able to get it.
SQL > select to_char (sysdate, 'yyyy') as 'mahesh tyagi' from dual;
Mahé
----
2015
SQL > select to_char (sysdate, 'yy') as 'Manu' from dual;
my
--
15
So I couldn't do 'Manu' or "mahesh tyagi" as the column name.
The column name is "mahesh tyagi" is simply displayed it shortened to sqlplus due to the known values in the column length.
create table year_test select to_char (sysdate, 'yyyy') "mahesh tyagi" double;
year_test / / DESC
You can change the way sqlplus displays the header of column with something like
column "mahesh tyagi" format a15
-
Write a SQL query with lines in columns
All the
I need help in writing a SQL query with lines in columns, let give u an example...
drop table activity;
CREATE TABLE 'ACTIVITY '.
(
"PROJECT_WID" NUMBER (22.0) NOT NULL,
VARCHAR2 (150 CHAR) "PROJECT_NO."
VARCHAR2 (800 CHAR) 'NAME '.
);
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1683691, '10007', 12-121');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1684994, '10008', 12-122');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1686296, '10009', 12-123');
Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (2225222, '9040', 12-124');
drop table lonet;
CREATE TABLE 'LONET.
(
VARCHAR2 (150 CHAR) "NAME."
NUMBER OF THE "ROOT."
VARCHAR2 (150 CHAR) "ENTRYVALUE".
);
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1683691, "LDE");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1683691, 'LME');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1683691, 'ICE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1683691, 'IKE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1686291, "QTY");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1686291, 'MAX');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1684994, "MTE");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1684994, 'MAC');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMT', 1684994, 'NICE');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMR', 1684994, 'RAY');
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1686296, "CAQ");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("PAP", 1686296, "QAQ");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("VANESSA", 1686296, "THEW");
INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("ANDR", 1686296, "REYL");
commit;
Link: activity.project_wid = lonet.root
look like output
Project_wid Project_no NAME GAC NAM BAG RAC 1683691 10007 12-121 LDE LME LCE LKE 1684994 10008 12-122 MTE null null MAC 1686296 10009 12-123 null null CAQ QAQ 2225222 9040 12-124 null null null null two problems, in that I am running
1. I dono how simply we can convert rows to columns
2. for root = 1683691, there are double NAM and RAC in lonet table... ideally these data should not be there, but since its here, we can take a MAX so that it returns a value
3. There are undesirables who should be ignored
Once again my thought process is that we join the activity and 4 alias table lonet.
ask for your help in this
Thank you
Hello
This is called pivoting.
Here's a way to do it:
WITH relevant_data AS
(
SELECT a.project_wid, a.project_no, b.SID
, l.name AS lonet_name, l.entryvalue
Activity one
LEFT OUTER JOIN lonet l.root = a.project_wid l
)
SELECT *.
OF relevant_data
PIVOT (MAX (entryvalue)
FOR lonet_name IN ("GAC" IN the gac
"NAM" AS nam
'BAG' IN the bag
"RAC" AS cars
)
)
ORDER BY project_wid
;
Output:
PROJECT_WID PROJECT_NO GAC NAM BAG RAC NAME
----------- ---------- ---------- ---------- ---------- ---------- ----------
1683691 12 - 10007 121 LDE LME LCE LKE
1684994 MAC MTE 10008 12-122
1686296 12 - 10009 123 QAC QAQ
2225222 9040 12 - 124
To learn more about swivel, see the FAQ in the Forum: Re: 4. How can I convert rows to columns?
Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!
-
I have a pdf form that has 4 columns, with each column having 28 check boxes and text between. I did so he goes by column, but when I do anything for a checkbox it takes it out of line. How can I keep that from happening?
You talk about the tab order? If Yes, go to Edit - Preferences - forms and make sure the box "Automatically adjust tab order when changing fields" is NOT checked.
-
Trying to hide a column but the header reappear on the following pages
Hi all
Here is my little problem, I have a table, a bit normal. What I try to do is the following:
I wish I could hide a full column based on the data. I was actually able to hide a column, but my problem is that when the table breaks into a second page, "header cell" on the second page of the column I hid reappear.
Here's how I did my stash:
-In table Initialize script, I check a condition, and if this condition is met, I'm hiding the header cell.
If (Verif.name4_we.rawValue == "" or Verif.name4_we.isNull) then
HeaderRow.Cell3.presence = "hidden".
endif
-For normal lines, I always check the same exact condition and if the condition is met, I hide the cell.
If (data. Page1.test.Table1.Verif.name4_we. RawValue == ' ' or data. Page1.test.Table1.Verif.name4_we. IsNull) then
.its presence $ = "hidden".
endif
This facility works pretty well if I only have one page:
5 is my header name (I know it might be confusing, I'm sorry), it's page 1, column 6, and 7 are in fact hidden.It's what happens on the following pages:
As you can see, only the header reappear, you can clearly see that the elements are still hidden, but because the header appear, it looks
as there was a full column.Does anyone have an idea of what could be my problem?
Thank you very much!
MaxAre you able to change the width of your columns?
This is the last trip, I did:
You must first, double-click the rule to open the palettes of drawing AIDS (or go into the top-> palettes-> drawing AIDS menu) and set the units to Points.
You need tables and a structure, a table which will show real information and a structure that will be imported into your program with the correct width (column DialogResult.Cancel will have a value of 0.001 in the structure). The structure is hidden in the page layout.
In your table initialize script, write something like this:
Set the width of columns by using our structure.//Empty imported have a width of 0.001
var width = Concat (data. Page1.struct.Col1, "pt."
data. Page1.struct.col2, "pt."
data. Page1.struct.col3, "pt."
data. Page1.struct.COL4, "pt."
data. Page1.struct.col5, "pt."
data. Page1.struct.col6, "pt."
data. Page1.struct.col7, "pt."
data. Page1.struct.COL8, "pt."
data. Page1.struct.col9, "pt."
data. Page1.struct.col10, "pt")
Table.columnWidths = width
Explanation: You concatenate each rawValue of your table that contains the width of your columns with "pt" (the unit), in this way, you can set the widths of all columns in a single command (Table.columnWidths = width).
This should resize the entire column, including the header. (It works on my side)
Don't bother to ask if you have any other questions
Max
-
Mr President
Jdev worm is 12.2.1
How to add two lines when the second row is not visible, but also gets the first data line too?
I want to add two lines like below picture, but want the second to remain invisible.
I asked this question but my way of asking was wrong, that's why for me once again.
Concerning
Try to follow these steps:
1. in the database table to add the new column "JOIN_COLUMN" and add the new sequence "JOIN_SEQ".
2. Add this new column in the entity object. (You can add this in entity object by right clicking on the entity object and then select "Synchronize with database" then the new column and press on sync)
3. in your bookmark create button to create only one line NOT 2 rows.
4 - Open the object entity--> java--> java class--> on the entity object class generate and Tick tick on the accessors and methods of data manipulation
5 - Open the generated class to EntityImpl and go to the doDML method and write this code
protected void doDML(int operation, TransactionEvent e) { if(operation == DML_INSERT) { SequenceImpl seq = new SequenceImpl("JOIN_SEQ", getDBTransaction()); oracle.jbo.domain.Number seqValue = seq.getSequenceNumber(); setJoinColumn(seqValue); insertSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn()); } if(operation == DML_UPDATE) { updateSecondRowInDatabase(getAttribute1(), getAttribute2(), getAttribute3(), getJoinColumn()); } super.doDML(operation, e); }
private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn) { PreparedStatement stat = null; try { String sql = "Insert into table_name (COLUMN_1,COLUMN_2,COLUMN_3,JOIN_COLUMN, HIDDEN_COLUMN) values ('" + value1 + "','" + value2 + "','" + value3 + "','" + joinColumn + "', 1)"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object joinColumn) { PreparedStatement stat = null; try { String sql = "update table_name set column_1='" + value1 + "', column_2='" + value2 + "', column_3='" + value3 + "' where JOIN_COLUMN='" + joinColumn + "'"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
-
limiting number of column in the 4.1 apex data loader?
Hi all!
Is there a limit on the number of column in the APEX 4.1 data loading page?
My DB object has 59 columns and they are all available in single colum drop of my load sample data table definition boxes.
On page two of the wizard created database load pages "data/table mapping" columns only 45 is indicated. These columns are correctly inserted in my table. The last 14 columns are ignored.
If anyone knows if there is a limitation and can it be extended?
Thanks for any reply and cordially
KaiNo, I don't have a solution for this.
Split the file within columns each, with the primary key that is repeated and then sting tables up to post upload could be easier than to use other roads.
And then there's always the good old SQL Loader and external Tables. But the integration of these into the Apex is not easy because Apex runs on the server and the file is usually the disk of HARD local to the client.
Kind regards
-
IMP on a full dump but a single importation of data
Dear Experts,
When I import the successful dump, I drop the existing schema ' SQL > drop user username cascade; "and import the dump by"system impdp... ". ". I would like to import an image to an existing instance but only the import of data and let the current and other packages metadata intact and unchanged on the instance of the existing said.
1. do I need to abandon the user prior to importation if my demands are foregoing?
2. If I have to drop the user, what should be the script.
3. for the import itself, should what settings I use?
4. What are the necessary things, I need to take into account before doing the import.
Your help and advice is greatly appreciated.
ARO
HadesTheHades0210 wrote:
HelloThank you for the answers.
My concern is the data in the dump are updated but not the metadata from the destination instance is use for development, metadata are updated but not the data.
Is there a way where I can update the data on the said instance without changing its metadata?
Thank you for your time.
Kind regards
HadesI already mentioned to use with the 'CONTENT' option, see below. It will be important that data with the option of "DATA_ONLY".
$impdp help=y Import: Release 11.2.0.2.0 - Production on Fri Feb 15 01:46:43 2013 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. ..... "CONTENT" Specifies data to load. Valid keywords are: [ALL], DATA_ONLY and METADATA_ONLY.
-
Hello
as the title suggests is that I want to do...
The problem I encounter is that I can't map my Weblogic roles at a level of demand - roles.
I do not see my weblogic on jazn-"Data.xml" roles and I can't create groups to the application level because
everything works as SQLAuthenticator on Weblogic...
I can get the role of user with EL as #{securityContext.userInRole ['ROLE']} but it cannot apply to jazn-"Data.xml".
Hope that if anyone can help...
Thank you
Renan.
PS: Jdev Studio Edition Version 11.1.1.1.0
JPA/EJB/ADF app
Published by: RenanMC on 12/09/2009 09:13Hello
you create groups of jazn-"Data.xml" and then use the weblogic.xml file to map these business groups for groups returned by the SQLAuthenticator
Frank
-
Getting file names of different groups in a data portal
Hello
I find it difficult to recover the file names of different groups in the data portal. For example, say that I loaded two different files of the same .tdms ext data portal that automatically assigns as two distinct groups. My goal is to get two groups using VBS in diadem 11.1 the name of the file.
Can someone help me in this regard.
Kind regards
X. Ignatius
Thank you Andreas.
I have a plugin that loads multiple files of lvm with their name sourcefile. Earlier it would be like Labview, Labview data1, data2 Labview data... When multiple files are loaded. Now, with this plugin attached in the startup script, all files are loaded with their original file names.
Attached plugins, set the LVM Custom load event. Vbs in the script, another starter accessory is the title of the main script function.
Kind regards
X. Ignatius
-
Close command of the groups in the data portal
Hello
can I use a command in a script to close all groups in the data portal (same as pressing "/" on the num pad).
Thank you
Gabriel
Hello Gabriel,
You can use
Portal.Structure.Collapse (Data.Root)
Tiara supports DATA and PORTAL API since version 11.
Greetings
Walter
-
I made a point of restoration but he restore in todays date whoing evil?
I made a point of restoration but he restore in todays date whoing evil?
Compare your procedure with this tutorial. It applies to both Vista and Windows 7.
http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-system-restore/
-
When I try to change the interactive report columns, then triggers the error: "unable to change column attributes. "ORA-01403: no data found. Pls tell me why?
You use listener EA3 ADR?
-
Group by with date range.
Hello
I'm looking for an efficient use of the group however the date range.
I have a table of transaction as below.
Date customer_no amount_paid
---------------------------------------------------------------
1st December 13 001 500
2 December 13 001 360
9 December 13 001 200
2 November 13 001 360
9 November 13 001 200
2 November 13 001 360
9 October 13 001 200
2 October 13 001 360
9 October 13 001 200
02 sep-13 001 360
200 001 13 - Sep - 09
............... etc.
I would like to see sum (amount_paid) by past varies from 1 to 30 days 31-60 days, 61 to 90 days.
Here are the results expected.
Amount_paid duration of customer
--------------------------------------------------------------
001 1 - 30 980
001-60 450 31
001 1200 61 - 90
002 1 - 30 300
002 31-60 490
002 61-90 320
003 1 - 30 450
......................etc.
I group by customer only the date range (1-30, 31-60, 61 - 90.etc).
Can someone make me a request for it.
Thank you...
Hedde.
Select customer_no,
case
When trunc (sysdate) - trunc (dt)< 31="" then="">
When trunc (sysdate) - trunc (dt)< 61="" then="">
another 61-90 '
the end time,
Sum (amount_paid) amount_paid
from your_table
where dt between sysdate - dt between 0 and 90
Customer_no group,
case
When trunc (sysdate) - trunc (dt)< 31="" then="">
When trunc (sysdate) - trunc (dt)< 61="" then="">
another 61-90 '
end
/
SY.
Maybe you are looking for
-
Reset Toshiba e-store account - 726
I have a journe touch, I downloaded and successfully installed the new firmware but now virtualstore no longer works. Can you please reset my account. Hoping that this will help solve the problem. After reset, I can receive a confirmation on the enam
-
HP Pavillion 500PC series - lack of Broadcom 802.11n network adapter
Hello I'm a newbie on this forum. I have gotHP Pavilion 500PC series, Windows 8 operating system, SN [personal information deleted]. There's a probem with low internet connection. Apparently, they say that the broadcom 802.11n network adapter is miss
-
HP s 4540: error device Base system in 10 windows Device Manager
Error device in system in the Device Manager in windows base 10. How can I solve this. Thank you. ID PCI\VEN_197B & DEV_2393 & SUBSYS_17F6103C & REV_30PCI\VEN_197B & DEV_2393 & SUBSYS_17F6103CPCI\VEN_197B & DEV_2393 & CC_088000PCI\VEN_197B & DEV_2393
-
Photosmart 7520: Unable to scan to e-mail photosmart 7520
Message saying not connected to the Internet, but it is
-
Windows Vista and June 2016 updates (patch Tuesday)
My operating system is Vista and I'm doing updates of Microsoft for June 14 (patch Tuesday) but the canning update just check updates. The summer of updates for hours now and everything continues to check updates. Is there a server problem or anyone