WITH COUNT and GROUP BY
I'm counting how many people have registered and COMPLETED a SPECIFIC set of units
Must have completed all 2 units on the line
Business - UNITS = ISR and DSW
Physiology or medicine: UNITS = DFC and XFG
Accounting - UNITS = DF and FGR
1 ID enlisted in the operational units and two units of medicine so I would count this ID for each line
ID 2 made only 1 of each line, so I won't count the ID. Want to only count who have completed all THE 2 units for each line
ID3 enlisted in two business units then count
4 ID was enrolled in two business units but fell on a count THAT as long as it isn't BOTH
CREATE TABLE DAN_PATH
(VARCHAR2 (12) ID,)
UNIT VARCHAR2 (12),
STATUS varchar2 (12),
LINE VARCHAR2 (12));
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'SRI', 'Registered ', ' BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'WA', 'Registered', 'ACCOUNTING');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'DSW', 'Registered ', ' BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'DFC', 'Registered', 'MEDICINE');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'XCV', ' registered', 'GENIUS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('1', 'XFG", 'Followed', 'MEDICINE');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('2', 'SRI', 'Registered ', ' BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('2', 'FD', ' registered', 'GENIUS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('2', 'FGR', 'Registered', 'ACCOUNTING');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('3', 'SRI', 'Registered ', ' BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('3', 'DSW', 'Registered ', ' BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('4', 'DF', 'Registered', 'ACCOUNTING');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('4', 'SRI', 'Coward', 'BUSINESS');
insert into DAN_PATH (id, UNIT, STATUS, LINE) values ('4', 'DSW', 'Registered ', ' BUSINESS');
GIVES:
ID | UNIT | STATUS | LINE |
1 | SRI | Registrants | COMPANY |
1 | DRF | Dropped | ACCOUNTING |
1 | DSW | Registrants | COMPANY |
1 | DFC | Dropped | MEDICINE |
1 | XCV | Registrants | ENGINEERING |
1 | XFG | Registrants | MEDICINE |
2 | SRI | Registrants | COMPANY |
2 | FDS | Registrants | ENGINEERING |
2 | FGR | Registrants | ACCOUNTING |
3 | SRI | Registrants | COMPANY |
3 | DSW | Registrants | COMPANY |
4 | DF | Registrants | ACCOUNTING |
4 | SRI | Dropped | COMPANY |
4 | DSW | Registrants | COMPANY |
I would like to get 2 queries that to me the line and the County of ID and the other to get me the ID
LINE | STUDENTS |
BUSINES | 2 |
MEDICINE | 1 |
ENGINEERING | 0 |
ACCOUNTING | 0 |
LINE | ID |
COMPANY | 1 |
COMPANY | 3 |
MEDICINE | 1 |
Hello
Let's start with 2 of the application; It's a little easier, and a solution for question 1 can be built on this subject:
WITH units AS
(
SELECT 'SRI' AS Unit, 'BUSINESS' AS a dual UNION ALL
SELECT 'DSW', 'BUSINESS' FROM dual UNION ALL
SELECT 'DFC', 'MEDICINE' IN UNION double, ALL
SELECT "XFG", 'MEDICINE' IN UNION double, ALL
SELECT 'DF', 'ACCOUNTING' FROM dual UNION ALL
SELECT 'FGR', 'ACCOUNTING' FROM dual UNION ALL
SÉLECTIONNEZ « FUBAR », « GÉNIE » DE la double
)
SELECT u.line
d.id
U units
JOIN dan_path d.unit d = u.unit
AND d.line = u.line
GROUP BY u.line
d.id
After HAVING COUNT (DISTINCT of CASE WHEN d.status = 'Registered' THEN d.unit END) = 2
COUNT (CASE WHEN d.status = 'Loose' THEN d.unit END) = 0
ORDER BY u.line
d.id
;
You can create a regular and permanent table for units, rather than use a WITH clause.
You can get the results desired for the application 1 by a GROUP BY on the results of the query 2, with the exception of a few things.
Quiz 1 must include all lines, even if no students not completed all units. To get these numbers 0, we can do an OUTER JOIN.
In addition, the HAVING of a query 2 clause eliminates the rows of the result set. We do not want to eliminate lines that fail under these conditions, we just want to know if they do not arrive or not. To do this, we have the same conditions inside a CASE, not a HAVING clause expression:
WITH units AS
(
SELECT 'SRI' AS Unit, 'BUSINESS' AS a dual UNION ALL
SELECT 'DSW', 'BUSINESS' FROM dual UNION ALL
SELECT 'DFC', 'MEDICINE' IN UNION double, ALL
SELECT "XFG", 'MEDICINE' IN UNION double, ALL
SELECT 'DF', 'ACCOUNTING' FROM dual UNION ALL
SELECT 'FGR', 'ACCOUNTING' FROM dual UNION ALL
SÉLECTIONNEZ « FUBAR », « GÉNIE » DE la double
)
query_2_results AS
(
SELECT u.line
d.id
CASE
WHEN COUNT (DISTINCT of CASE WHEN d.status = 'Registered' THEN d.unit END) = 2
COUNT (CASE WHEN d.status = 'Loose' THEN d.unit END) = 0
THEN 1
END as finished
U units
LEFT OUTER JOIN dan_path d.unit d = u.unit
AND d.line = u.line
GROUP BY u.line
d.id
)
SELECT line
COUNTY (completed) as students
OF query_2_results
GROUP BY line
;
I guess just some of your needs.
Tags: Database
Similar Questions
-
Rewrite the query with joins, and group by
Hello
It's an interview question.
Table names: bookshelf_checkout
virtual library
And the join condition between these two tables is title
We need to rewrite under request without using the join condition and group by clause?
When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out" FROM bookshelf_checkout bc,bookshelf b WHERE bc.title(+)=b.title GROUP BY b.title;
Kindly help me on this.
Thank you
SuriSomething like that?
1 WITH books AS ( 2 SELECT 'title 1' title FROM dual UNION ALL 3 SELECT 'title 2' FROM dual UNION ALL 4 SELECT 'title 3' FROM dual ), 5 bookshelf AS ( 6 SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL 7 SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL 8 SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual ) 9 SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs 10 UNION 11 (SELECT b.title, NULL FROM books b 12 MINUS 13* SELECT bs.title, NULL FROM bookshelf bs) SQL> / TITLE MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE) ------- ------------------------------------------------------------ title 1 14 title 2 44 title 3
Lukasz
-
Unable to get the database searched with MAX and GROUP BY function
Hello
All the
I have a table as below:
COLUMN TYPE
User_id VARCHAR2 (10 byte)
ID_processus VARCHAR2 (30 bytes)
END_TIME DATE (STAMP)
TO_LOC VARCHAR2 (12 bytes)
TO_LOC_TYPE VARCHAR2 (15 bytes)
FROM_LOC VARCHAR2 (12 bytes)
ITEM_ID VARCHAR2 (25 bytes)
CASE NUMBER (12.4)
LMS_UDA1 VARCHAR2 (250 bytes)
AREA VARCHAR2 (2 bytes)
I only want to get one record with all the columns, have only one clause MAX (END_TIME)
But the other column value of the difference.
When I use MAX (END_TIME) and GROUP OF USER_ID, ID_processus, CASE...
the sql did not a single record,
It gives the number of records
Please help me on this
Concerning
Saven>
I only want to get one record with all the columns, have only one clause MAX (END_TIME)
But the other column value of the difference.
>
Maybe it's not possible because it depends on your data.If the combination of all columns except END_TIME is not unique then there will be multiple records; a record for each unique combination (GROUP BY) of all other columns.
The only way to ensure that a record is
SELECT MAX(END_TIME) FROM myTable
-
I'm working on the cover search active county from COV_CHG_EFF_DATE for the ID of strategy and Futures (sample data are for a single policy). The rule for the coverage of assets are counted as below
I find LAST_VALUE limit with the help of count (distinct COVERAGE_NUMBER) and the LINES BETWEEN Unbounded preceding AND 1 previous characteristic. Is there another better logical or analytical function in support of the application to calculate the value of aggregation based set of rules? Data from table and sample before if anyone find solution. Thank you.Transaction Type Count 01, 02 +1 06, 07 +1 09, 10 -1 03 0 COVERAGE_NUMBER TRANSACTION_TYPE COV_CHG_EFF_DATE Active_Cover_Count 01 01 22/OCT/2011 2 02 01 22/OCT/2011 2 04 02 23/OCT/2011 3 05 02 28/OCT/2011 4 05 09 30/OCT/2011 2 02 09 30/OCT/2011 2 05 06 03/NOV/2011 3 05 03 03/NOV/2011 3 05 09 05/NOV/2011 0 01 09 05/NOV/2011 0 04 09 05/NOV/2011 0
----------------------------------------------------------------------------------------------------------------------------------------
Published by: 966820 on October 30, 2012 20:30drop table PC_COVKEY_PD; create table PC_COVKEY_PD (PC_COVKEY varchar(30), POLICY_NUMBER varchar(30), TERM_IDENT varchar(3), COVERAGE_NUMBER varchar(3), TRANSACTION_TYPE varchar(3), COV_CHG_EFF_DATE date, TIMESTAMP_ENTERED timestamp ); delete from PC_COVKEY_PD; commit; insert into PC_COVKEY_PD values ('10695337P3021MC0020012', '10695337P3', '021', '002', '02', to_date('22/OCT/2011','DD/MM/YYYY'), cast('22/SEP/2011 03:10:12.523408 AM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0010012', '10695337P3', '021', '001', '02', to_date('22/OCT/2011','DD/MM/YYYY'), cast('22/SEP/2011 03:10:12.523508 AM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0040012', '10695337P3', '021', '004', '02', to_date('22/OCT/2011','DD/MM/YYYY'), cast('22/SEP/2011 03:10:12.864153 AM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0040032', '10695337P3', '021', '004', '03', to_date('22/OCT/2011','DD/MM/YYYY'), cast('22/SEP/2011 03:10:12.865153 AM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0050012', '10695337P3', '021', '005', '02', to_date('22/OCT/2011','DD/MM/YYYY'), cast('22/SEP/2011 03:10:12.976483 AM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0020042', '10695337P3', '021', '002', '09', to_date('22/NOV/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.006435 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0040042', '10695337P3', '021', '004', '03', to_date('22/NOV/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.135059 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0050042', '10695337P3', '021', '004', '09', to_date('22/NOV/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.253340 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0020042', '10695337P3', '021', '004', '03', to_date('22/NOV/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.363340 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0040032', '10695337P3', '021', '005', '09', to_date('29/NOV/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.463340 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0050032', '10695337P3', '021', '005', '03', to_date('29/DEC/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.563340 PM' as timestamp)); insert into PC_COVKEY_PD values ('10695337P3021MC0020012', '10695337P3', '021', '002', '03', to_date('30/DEC/2011','DD/MM/YYYY'), cast('16/FEB/2012 02:26:00.663340 PM' as timestamp)); commit;
-
Help on report with max and group of?
Hello I need to display the next report
SELECT THE TABLE TABLE_NAME, NOM_PARTITION, LAST_ANALYZED IN USER_TAB_PARTITIONS;
However, I need to display the table table_name time with sound (partition_name) MAX current (assuming that the names are P2010, P2011, etc...) and when he was last_analyzed
What is the most effective way to do it? Subselect statement? Inner join?
Thank you!Hello
Using a GROUP BY:
SELECT table_name, max(partition_name) as partition_name, max(last_analyzed) keep (dense_rank last order by partition_name) as last_analyzed FROM all_tab_partitions GROUP BY table_name ;
Another solution would be a TOP - n query, using the ROW_NUMBER analytic function:
SELECT table_name, partition_name, last_analyzed FROM ( SELECT table_name, partition_name, last_analyzed , row_number() over( partition by table_name order by nlssort(partition_name,'NLS_SORT=BINARY') desc ) as rn FROM all_tab_partitions ) WHERE rn = 1 ;
Note that I had to use the NLSSORT function to get the same result as the value that the query GROUP BY.
Depending on your NLS DB/SESSION settings, you may not do.Edited by: odie_63 Feb 4. 2011 14:31
-
I tried to understand what is the problem with a large sql query that does not change what I do.
Have managed to isolate the part which is a failure, but I get the error message:
ORA-00979: not a GROUP BY expression
is not very useful.
I suspect there is something fundamentally wrong in what I'm trying to do.
I had to anonimise the names of the tables and fields that the data that I use is quite sensitive, but it should not forget the problem.
Here is the query:
DATA_TABLE has (among others) of fields:select case when a='100' and cost in (select cost from lookup) then '100' else b end as main, count(*) from data_table group by case when a='100' and cost in (select cost from lookup) then '100' else b end
a, b, and the cost
search contains the field:
cost
All fields are VARCHAR2 (255)
If I remove the count (*) and any group of the query statement runs it is to say:
This shows that the stated case is valid - then why I can not combine the count and group of?select case when a='100' and cost in (select cost from lookup) then '100' else b end as main from data_table
If this is a reason of syntax is there another solution that I can possibly use subqueries to work around the problem - I prefer to avoid this and can't really make the case in a decoding without him make mess.
Oracle version:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.
TIA
Published by: user8378443 on May 11, 2011 10:26Try like this,
SELECT MAIN, COUNT (*) FROM (SELECT CASE WHEN A = '100' AND COST IN (SELECT COST FROM lookup) THEN '100' ELSE b END AS MAIN FROM data_table) GROUP BY MAIN
G.
-
GROUP BY ROLLUP with subtotals category grouped
Hello
I need categories to have group totals as in the example below. Note that California has its own category subtotals and total.
I could do with unions, a line type column, and the sort, but that would mean read the entire table for each subtotal total snd.
Any suggestions?
Thanks in advance for your help,
Lou
My data
CITY STATE CATEGORY NBR
California Los Angeles AA 1
California Los Angeles BB 2
Los Angeles, California 3 CC
California San Diego AA 4
California San Diego BB 5
California San Diego 6 CC
California San Francisco AA 7
San Francisco California 8 BB
California San Francisco CC 9
Desired result
CITY STATE CATEGORY NBR
California Los Angeles AA 1
California Los Angeles BB 2
Los Angeles, California 3 CC
California, Los Angeles 6
California San Diego AA 4
California San Diego BB 5
California San Diego 6 CC
California at San Diego 16
California San Francisco AA 7
San Francisco California 8 BB
California San Francisco CC 9
California, San Francisco 24
California AA 12
California BB 15
California CC 18
Grand Total 45Hello
SELECT state, city, category , SUM (nbr) AS nbr FROM table_x GROUP BY CUBE (state, city, category) HAVING GROUPING (state) = 0 ORDER BY state, city, category;
Basically what you want.
The numbers aren't quite what you've posted.
The "Grand Total" line, said "Califoirnia" instead. You can fix that with CASE and GROUPING. -
Need a clarification on the concept of 'World' and 'Group' with regard to CPU reviews
All-
I am investigating questions of CPU usage for one of my guests with esxtop. Can someone clarify the concept of 'World' and 'group '? Many of my guests have a 7 or 11 NWLD and I'm trying to figure out exactly this means. What I gather is the following:
A guest has many worlds
There is one guest per group
A group contains many worlds
Can someone also explain the purpose to describe the use of the processor in this way?
Megan
Hello.
Check it out "[interpretation statistical esxtop | ]. "[http://Communities.VMware.com/docs/doc-9279.pdf]" document. «[The planner of UC in VMware® ESX 4 |]» [ http://www.vmware.com/files/pdf/perf-vsphere-cpu_scheduler.pdf] "white book is also a good reference.
Good luck!
-
How can I restore my tabs and groups of tabs after a update to version 36.0?
I work with many tabs when I use Firefox. I keep classified in groups of tabs, which helps to separate the different children to work I do and interests I have. I have been using this environment for years. When I started my job today, Firefox updated to v36.0, and noted the following behaviors:
1. There is only one group of tabs when you try to display tabs at Panorama, as opposed to a dozen groups;
2. normally if the hidden tabs (tabs in the same group as the startup group, and not the default page) downloading of content to what the user clicks on, icon, if any, and the name of the page will show on the tab currently, the tabs display 'New tab' and no icon. It seems, however, the number of tabs that exist across all groups of tabs, but are now ghosts this default value, a group of tabs. I must add, however, I do not count the number of tabs, so I can't be exactly. When you click on it, there is just a blank page. It is so strange that Firefox knows they are there but cannot simply attach the address.
I tried to restore the following files from my backup of Windows Home Server to the folder AppData\Roaming\Mozilla\Firefox\Profiles\ .default < gobbletygook >:
1. in the sessionstore-backups folder, I replaced the files previous.js, recovery.bak and recovery.js (not all of the upgrade ~) with the files yesterday and the day before yesterday.
When that did nothing, I replaced
2 sessionCheckpoints.json
I do not see any file with a recent date that seems to be the one that I have to restore. I should add that I don't see hidden files. I thought about the restoration of the whole of the batch, but didn't know how it would affect the program v36.0 and the profile on 35.0.1 files.
I have deadlines this week and must immediately restore my environment in order to make these possible. I have no address list on my Web pages to work in IE or other. Any help would be much appreciated.
On a second note, I had been wondering recently if this tab group environment is an appropriate way to maintain my work environment. Sometimes, during the opening of Panorama, I would get an error saying a script takes too much time, but if I clicked on continue, it would display the groups in a few seconds. I considered bringing it in bookmarks, but it would be tedious and more difficult to access and open several tabs. Initially, I tried tabs groups thinking it was just a matter of maintaining a table of addresses (in tabs) with a name or an ID of tab group. How that might go wrong? Well, there, so it is obviously more complicated than that, and I did not know that upgrades would affect the data of a personal nature. That I should abandon the use of tab groups?
With the help of information from the user, ptressel, in a post here on the existence of sessionstore.js when version 33 was released, I could easily get my tabs and groups of tabs as follows:
- close Firefox and, perhaps, wait a few seconds (30 years?) for any final closing of files;
- Check if you have a sessionstore.js file in your profile folder, named as I documented in my original post above.
- If this is not timestamped before the discovery of your problem, open the sessionstore-backups folder.
- Check if the recovery.js file is properly stamped and, if not, the recovery.bak.
- At this point, you are likely to find that none of them is before your problem occurring. If so, open your backups from this folder and go through steps 2 to 4 to find a file before your problem occurring.
- When you find a file, copy it to the root of your current profile folder and name it, "sessionstore.js.
- Open Firefox. Mine opened upwards as you wish.
It is a solution for Windows. Sorry I can't comment on other platforms, but I'd bet it's just a copy of file and change of name, it is likely even.
For Windows users, you can find you must sign out and sign in as administrator in order to access backups. You must not logoff your standard account, but do have Firefox closed as described above.
Hope that helps.
-
Ask for help with the query group by
Hello
I have the following table with values structure
I have the following requirement, the output should be:CREATE TABLE DUMMY ( SR_NUMBER VARCHAR2(100 CHAR), ASSIGNMENT_GROUP VARCHAR2(100 CHAR), REASSIGNMENT_COUNT VARCHAR2(100 CHAR), CREATED DATE, CLOSED DATE, TARGET_DATE DATE ) insert into dummy values('AAA','A','1','02-OCT-11','25-OCT-11','09-OCT-11'); insert into dummy values('ABC','A','1','03-SEP-12','26-SEP-11','10-SEP-11'); insert into dummy values('AVB','A','1','02-NOV-13','25-NOV-13','09-NOV-13'); insert into dummy values('AFT','B','1','02-OCT-11','25-OCT-11','09-OCT-11'); insert into dummy values('ACS','B','1','02-JAN-12','25-JAN-12','09-JAN-12'); insert into dummy values('AVC','B','1','02-OCT-13','25-OCT-13','09-OCT-13'); insert into dummy values('AAD','B','1','02-MAR-14','25-MAR-14','09-MAR-14'); insert into dummy values('AAA','C','1','02-OCT-11','25-OCT-11','09-OCT-11'); insert into dummy values('AAA','D','1','02-JUN-11','25-JUN-11','09-JUN-11'); insert into dummy values('AAA','E','1','02-APR-12','25-APR-12','09-APR-12'); insert into dummy values('AAA','A','1','02-FEB-13','25-FEB-13','09-FEB-13'); ?
Number of ticket (sr_number)
% of tickets inside the DL
Number of tickets inside the DL
Average cycle time (cycle time = closing date - date of creation)
Total cycle time (cycle time = closing date - date of creation)
Number of reallocations (sum)
DL - (deadline) formula is, closed date < = target_date
This should be displayed, grouped by year, then month, then the assignment group. The values must be in descending order (dates) is not sure that group in operation here.
I am able to write the code base of the foregoing, but group from the year, month, and group assignment is pretty confusing to me.
Can someone give me a voucher code...This may not give you exactly what you want, but if all goes well, it will give you something to work with:
WITH tickets AS ( SELECT TO_CHAR(created, 'YYYY') created_year, TO_CHAR(created, 'MM') created_month, assignment_group, COUNT(sr_number) ticket_count, AVG(closed - created) avg_cycle_time, SUM(closed - created) tot_cycle_time, COUNT(reassignment_count) reassign_count FROM dummy GROUP BY TO_CHAR(created, 'YYYY'), TO_CHAR(created, 'MM'), assignment_group ), dl_tickets AS ( SELECT TO_CHAR(created, 'YYYY') created_year, TO_CHAR(created, 'MM') created_month, assignment_group, COUNT(sr_number) ticket_in_dl_count FROM dummy WHERE closed <= target_date GROUP BY TO_CHAR(created, 'YYYY'), TO_CHAR(created, 'MM'), assignment_group ) SELECT t.created_year, t.created_month, t.assignment_group, t.ticket_count, NVL(dl.ticket_in_dl_count, 0) ticket_in_dl_count, NVL(dl.ticket_in_dl_count/t.ticket_count, 0) * 100 pct_ticket_in_dl_count, t.avg_cycle_time, t.tot_cycle_time, t.reassign_count FROM tickets t, dl_tickets dl WHERE t.created_year = dl.created_year (+) AND t.created_month = dl.created_month (+) ORDER BY created_year DESC, created_month DESC
Published by: user1983440 on May 27, 2013 15:47 - added reassign_count
Published by: user1983440 on May 27, 2013 15:54 - added ORDER BY
-
Problems with export and import
I have a problem with export and import
Here's what I did...
Here is my log exportexp "'/ as sysdba'" PARFILE=parfile.txt PAFILE TABLES=user1.Table1 file=Table1_1006.dmp LOG=Table1_1006.log query="where to_char(processeddate,'YYYYMMDDHHMISS') between to_char(to_timestamp('1911-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS'),'YYYYMMDDHHMISS') and to_char(to_timestamp('2011-10-06 16:46:26','YYYY-MM-DD HH24:MI:SS'),'YYYYMMDDHHMISS')"
Then I started to importset and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... Current user changed to user1 . . exporting table Table1 16019049 rows exported EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. EXP-00091: Exporting questionable statistics. Export terminated successfully with warnings.
but I have no lines of base2/database2/rdbm15> imp "'/ as sysdba'" file=Table1_1006.dmp fromuser=user1 touser=user1 tables=Table1 log=imp_Table1_1006.log Import: Release 10.2.0.5.0 - Production on Thu Oct 6 19:57:01 2011 Copyright (c) 1982, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export file created by EXPORT:V10.02.01 via conventional path import done in US7ASCII character set and AL16UTF16 NCHAR character set . importing user1's objects into user1 IMP-00015: following statement failed because the object already exists: "CREATE TABLE "Table1" ("APPROVALTRACEID" VARCHAR2(64), "REQUESTOR" "EID" VARCHAR2(9), "EID" VARCHAR2(9), "FIRSTNAME" VARCHAR2(32), "LASTNAME" V" "ARCHAR2(32), "MIDDLEINITIAL" VARCHAR2(8), "TIER" VARCHAR2(3), "JOBTITLE" VA" "RCHAR2(64), "JOBCODE" VARCHAR2(10), "EMPLOYEETYPE" VARCHAR2(2), "CONTRACTOR" "TYPE" VARCHAR2(2), "EMPLOYEESTATUS" VARCHAR2(2), "COSTCENTER" VARCHAR2(10)," " "COSTCENTERDESCRIPTION" VARCHAR2(50), "CONTRACTENDINGDATE" VARCHAR2(8), "A" "CCOUNTSTATUS" VARCHAR2(2), "LOGINID" VARCHAR2(70), "APPLICATIONGROUP" VARCH" "AR2(50), "APPLICATIONNAME" VARCHAR2(50), "APPLICATIONID" VARCHAR2(12), "LEV" "EL1" VARCHAR2(512), "LEVEL2" VARCHAR2(512), "LEVEL3" VARCHAR2(512), "LEVEL4" "" VARCHAR2(512), "LEVEL5" VARCHAR2(512), "PROFILECODE" VARCHAR2(50), "PROCE" "SSEDDATE" DATE, "APPROVERMANAGEREID" VARCHAR2(9), "APPROVERMANAGERDELEGATEE" "ID" VARCHAR2(9), "APPROVERT4MANAGEREEID" VARCHAR2(9), "APPROVERT4MANAGERDEL" "EGATEEID" VARCHAR2(9), "APPROVERAPPOWNEREID" VARCHAR2(9), "APPROVERAPPOWNER" "DELEGATEEID" VARCHAR2(9), "PERFORMEREID" VARCHAR2(9), "NATIONALID" VARCHAR2" "(30), "COUNTRYCODE" VARCHAR2(9), "PASSPORTID" VARCHAR2(20), "DATEOFBIRTH" V" "ARCHAR2(15), "CITYOFBIRTH" VARCHAR2(15), "VENDORNAME" VARCHAR2(50), "VENDOR" "MANAGERNAME" VARCHAR2(50), "VENDORMANAGERID" VARCHAR2(9), "VENDORADDRESS1" " "VARCHAR2(100), "VENDORADDRESS2" VARCHAR2(100), "VENDORSTATEPROVINCE" VARCHA" "R2(15), "VENDORCOUNTRYCODE" VARCHAR2(9), "VENDORZIPPOSTALCODE" VARCHAR2(9))" " PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 4076863488 " "NEXT 1048576 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) " " LOGGING NOCOMPRESS" Import terminated successfully with warnings.
[server1]database2 /database2/rdbm15> sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Thu Oct 6 19:59:17 2011 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select count(*) from user1.Table1; COUNT(*) ---------- 0 SQL> exit
Published by: user3636719 on October 6, 2011 17:23SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production CORE 10.2.0.5.0 Production TNS for HPUX: Version 10.2.0.5.0 - Production NLSRTL Version 10.2.0.5.0 - Production
could ignore = y, and then try again. It should work
Concerning
Julien -
A query containing a subquery and Group By all-in-one
Hi people,
Any interesting fact but nerve racking situation I have here. I have a question that I have to do counts and amounts and I also need to have a Sub inside query. When I run my application, I get an error like this:
Error in the command line column: 4:36
Error report:
SQL error: ORA-00979: not a GROUP BY expression
00979 00000 - "not a GROUP BY expression"
* Cause:
* Action:
Here's my query:
If I replace it with the acc.account_num (subquery) with a number that is in the database, then my request works well.select distinct to_char(c.start_date,'YYYY') start_date, substr(acc.account_num,1,12) account_number, ( select acc2.account_desc from student_account acc2 where acc2.account_num = acc.account_num and acc2.account_type = 'A' ), COUNT(distinct(s.student_id)) from student s, student_account acc, course c where s.course_id = c.course_id and s.account_num = acc.account_num and to_char(c.start_date, 'YYYY/MM/DD') between '2004/01/01' and '2009/12/31' group by to_char(c.start_date,'YYYY'), substr(acc.account_num,1,12) order by 1;
Published by: Roxyrollers on March 29, 2011 16:45Hello
We don't know what you want. It would really help if you posted some examples of data (CREATE TABLE and INSERT statements) and the results desired from these data.
Are you sure that the scalar subquery will return ever more than one line? If so, you can wrap in a MIN or MAX aggregate function, as I've suggested before:
select distinct to_char(c.start_date,'YYYY') start_date, substr(acc.account_num,1,12) account_number, MIN ( ( select acc2.account_desc from student_account acc2 -- Changed where acc2.account_num = acc.account_num and acc2.account_type = 'A' ) ), -- Changed COUNT(distinct(s.student_id)) from student s, student_account acc, course c where s.course_id = c.course_id and s.account_num = acc.account_num and to_char(c.start_date, 'YYYY/MM/DD') between '2004/01/01' and '2009/12/31' group by to_char(c.start_date,'YYYY'), substr(acc.acct_acc_num,1,12) order by 1;
It seems that you could also simplify the query and make more fast, eliminating the scalar subquery. The table there is already part of the main query, you can do something like this:
SELECT TO_CHAR (c.start_date, 'YYYY') AS start_date , SUBSTR (acc.account_num, 1, 12) AS account_number , MIN ( CASE WHEN acc.account_type = 'A' THEN account_desc END ) AS a_desc , COUNT (DISTINCT s.student_id) AS student_id_cnt FROM student s , student_account acc , course c WHERE s.course_id = c.course_id AND s.account_num = acc.account_num AND c.start_date BETWEEN DATE '2004-01-01' AND DATE '2009-12-31' GROUP BY TO_CHAR (c.start_date, 'YYYY') , SUBSTR (acc.acct_acc_num, 1, 12) ORDER BY start_date;
I guess that course.start_date is a DATE. Instead of converting each start_date to string (so you can see if it is in the right range), it is more efficient and less prone to error, compared to other DATEs, as shown above.
It is very strange that you
substr(acc.account_num,1,12)
in the select clause, but
substr(acc.acct_acc_num,1,12)
in the GROUP BY clause. Did you mean having the same column in both places?
Yet once, without seeing some examples of data (CREATE TABLE and INSERT statements) and the results desired from this data, I can't do much.
-
Combine in a single line: check the box Case() and Group BY
Hello
I have a little problem and it seems my knowledge and possession is simply not enough good to slove it.
To better understand my question here an example (the actual query is too large):
Data:
NAME, CASE_NO, GO_TAG
Tom 10 GB
Tom 15 GB
Tom 20
30 Tim
Tim 40
My query looks like this:
SELECT NAME,
CASE
WHEN (GO_TAG IS NOT NULL) THEN wm_concat (CASE_NO)
ANOTHER NULL
END WITH_GO_TAG
CASE
When wm_concat (CASE_NO) (GO_TAG IS NULL) THEN
ANOTHER NULL
END WITHOUT_GO_TAG
GROUP BY NAME, GO_TAG;
Now what I get output:
NAME, WITH_GO_TAG, WITHOUT_GO_TAG
Tom, 10, 15', "
Tom, ", '20'
Tom, 10, 15', "
Tom, cm, 30, 40'
Here's my problem: I want a line instead of two lines for "Tom."
It looks like: Tom, 10 ', 15', 20'
Is this possible?
You should know that I coded those SQL things to right directly in this forum to show you my problem... hope you can understand it :-)
Hope someone can help me in this case.
Oh, almost forgot, I (or better: my company) use Oracle Version: 10g
See you soon,.
PhilHello
Thank you. It's clearer.
Did you count 5 lines of sample data, or 10?
In SQL * Plus, when you finish an order with one; and then have a /, the / means "repeat the last command. So, when I runINSERT INTO EXAMPLE VALUES ('Tom', 10, 'go'); /
I get 2 identical rows. I suppose you want only 1.
When you say ' GROUP BY name, go_tag ', the output contains a line for each distinct combination of name and go_tag.
If you want just one row for each distinct value of the name, just say 'GROUP BY name. If we are not group by go_tag, we must be careful that any reference to go_tag in the SELECT clause is like an aggregation function argument, like this:SELECT NAME, STRAGG (NVL2 (go_tag, case_no, NULL)) AS with_go_tag, STRAGG (NVL2 (go_tag, NULL, case_no)) AS without_go_tag FROM EXAMPLE GROUP BY NAME;
NVL2 (a, x, y) is equivalent to
CASES WHERE an IS NOT NULL THEN x ELSE y END to this problem, I found NVL2 easier than CASES to read and understand, but I don't maintain your code, then you should use your way of thinking is the best. -
Is it possible to save the current tabs and groups so that they can be recharged at any time?
My Firefox crashes sometimes, and when I start it up again, my groups and tabs that I had are lost, so I need to recreate my history window. Is there a way I can save the groups that I have with the tabs on the inside so that I can retrieve them at a later date.
"I say that Firefox does not save the whenever I close the browser, so I'm güssing there a file somewhere that contains this information, if I know how is called this file I could save it on my regular schedule and retrieve them if I had to, of course the best solution would be to have a ' save the groups ' & 'Support groups' in the menu.Thanks in advance
DayoJ(PIN) App tabs and groups of tabs (Panorama) are stored in session data in the sessionstore.js file in the Firefox profile folder.
You can use this button to go to the Firefox profile folder currently in use:
- Help > troubleshooting information > profile directory: see file (Linux: open the directory;) Mac: View in the Finder)
- http://KB.mozillazine.org/Profile_folder_-_Firefox
-
Research Protect deleted all my tabs and groups of Firefox
I had about 200 tabs grouped together in about 30 groups of 31.0 Firefox (latest version). The Group appeared when I clicked on the icon to the left of the button "minimize" or press CTRL + SHIFT + E. It is called "your Firefox tabs - group". I also use Xmarks, but I have disabled Synchronization tab recently.
Generally all the tabs and their groups have been saved when I closed Firefox. Today I opened Firefox and all tabs and groups disappeared! Instead, it opens some search engine called Trovi (www.trovi.com) with "bing results. Its the same in Chrome, Opera and IE.
My OS is Windows 8.1 update 1 with all updates installed. My antivirus is Avast! with all updates installed. There was some malware installed of course, but I'm not awake me. I ran a 'full system test' in Avast! latest updates, which is the deeper analysis that I know (without my laptop HP ProBook 4730 s restaring). No viruses were found.
I'm suspecting a program called 'Research Protect' version 2.16.10.61 'Client Connect Ltd. It was installed with PowerISO 6.0 x 64.
I tried to run the system restore, but it seems that all the restore points I ever created are now deleted! I discovered this by opening the system properties-> system-> system restore Protection. However, 'Protection' is 'On' for my system disk.
How can I restore my tabs and groups? It is extremely important for me.
Accidentally, I posted my question twice - my apologies. I marked this as resolved and will continue to ask for help on the other.
https://support.Mozilla.org/Ta/questions/1014087
Thank you!
Maybe you are looking for
-
I am trying to load windows 10 on any new Mac mini and I got in trouble. ISO on a USB key, I downloaded directly from microsoft (I used it for other facilities and no mac and mac) plus I have a brand new DVD, I tried as well (although windows pro 8.1
-
Activation of Mini DisplayPort after transplanting HDD internal?
Just transplanted a SSD internal in a 2008 Mac Pro (who had two DVI input) in a most powerful 2009 Mac Pro (which has a DVI input and two mini Displayport inputs). Trying to connect two monitors, as well as the DVI input is fine but entered Minies Di
-
I have a temperature application on my computer on notify me if the temperature of the CPU exceeds of 66º C. It lasts 38 ºC to 47º C. It seems that the warning lights up all the days. When I look at the two process Activity Monitor use approximately
-
LabVIEW 2014 SP1, hardware and real-time PXI
I'm doing my third LabVIEW Wipe/reinstall in as many days, completely frustrated (and after several calls an hour with the support of NEITHER). Here's the situation: I wrote a fairly large (1000 VI) project of Acquisition/control of our graduate stu
-
First character left in file by reading the first line in text file
When you use the function of reading text from a file file, I noticed that the 1st character is left in the file. I read the line correctly. When adding a 2nd line this character is in the file. Part vi code is attached. Any ideas? Thank you. Elik