Power Query for Excel - Need Help with Oracle SQL Syntax
Hello everyone,
I am new to Power Query and am not able to figure this out. I am trying to pull in data into my Excel spreadsheet using a specific Oracle SQL query. While in query editor, how do I take the Oracle.Database function and add my SQL statement?
I already know what I want, I don't want it to download all the table names. According to the help page, I should be able to do this but it does not provide a syntax example
Also, I don't understand what "optional options as nullable record" means.
Below is what function and arguments the help page notes. How do I use this?
Oracle.Database(server as text, optional options as nullable record) as table
Any help is greatly appreciated.
Thank you,
Jessica
When I try this, I get an error
DataSource.Error: Oracle: Sql.Database does not support the query option 'Query' with value '"Select * from Owner.View_Name"'. Details: null
I'm trying to download oracle data from a view into power query - Power Query navigator does not list th eviews from my source, it lists only the tables. When I try write sql statements, it throws me the above
error. This is what I tried
Oracle.Database("Source/Service",[Query="Select * from Owner.View_Name"])
Any ideas how to fix this?
Similar Messages
-
Hi,
I need some help... if someone can help its great.
I need to make a statement in Oracle SQL that read data from a file and insert in a Oracle Database ... if someone can show me the syntax of it i appreciate..
ThanksOkay, I see you followed the advice in that other thread and started a new post for you question. Congratulations. Your next lesson in forum etiquette is to give your posts a more relevant subject. Pretty much everybody who posts here needs help with oracle; if they need help with cooking catfish they've come to the wrong place.
It that other thread I suggested using SQL*Loader or External Tables might be a more suitable solution. Find out more.
Cheers, APC -
Power Query for Excel login/connection issue.
Hi all
I have recently installed Power Query for Microsoft Excel in MS Office 2013.
I can connect successfully to the all the BI Universes, create queries & design reports in Excel.
The problem that I have is that I can only do this with the Administrator account. The Admin account is the only account that can connect successfully to the BI universes.
I have created test user accounts,test groups and assigned security to basically reflect the same rights as the Admin group, but to no avail.
I have also assigned security to these users & groups on the application level (RESTful Web Service, Universes, Connections) , but no luck.
It constantly says : "Access to the Resource is forbidden"
The last thing I want to do is make the users part of the Administrator group. I'm sure you guys would agree that that would be like opening Pandora's BoxHi Liang,
Power Query is part of Excel 2016 and can be found under the Data tab.
Regards,
M. -
Need help with help pse4 not supported by adobe. how to do topics not available and I have never used any thing like this. Help says there is a download but have not been able to get it. What's a rookie to do ? Is there somewhere I can go to find out how to use PSE4?
The internet is overflowing with tutorials on PSE. Just google what you want and include Photoshop Elements 4 as part of your search term, or go to the library and they may have several different books on PSE 4. For PSE 4, you won't find a mac specific book, but that doesn't matter because the editor is the same on either program. Just substitute Command for Ctrl and Option for Alt in the keystrokes, and ignore anything about the organizer.
Some popular sites for learning elements:
http://www.photoshopelementsuser.com/
lynda.com
eclecticacademy.com
youtube has a lot of video tutorials, too. -
Help with Oracle SQL to strip unwanted characters
Hello,
I have 2 columns (Weight and Height) where I need to strip the alpha characters and convert them to numbers (I am required to derive additional columns where I need to present
these values in inches, cm, KG, LB, etc. (and thus the need to convert them to numbers). I am too much a novice to understand the best way to convert these columns into numbers (same precision as you see here).
See the image below for a sample of what these columns currently contain. I simply need help with the Oracle SQL code to parse/convert these vales into number. Thanks in advance for your assistance!
DaveHi,
In addition to
Erland Sommarskog's comment which is of course correct and this i not the forum to ask question about Oracle, I dont want to leave you without a lead :-)
The solution both in SQL Server and Oracle should based on Regular Expressions. I highly recommended NOT to use T-SQL solutions in this case, as mentioned above, unless this is a very small table and the need is very simple and include finding one point
in the string as in
SaravanaC solution (when he assume thge string format is based on 2 parts (1) Number + (2) unit type).
In Oracle there is a build in Regular Expressions option as mentioned here: http://docs.oracle.com/cd/B12037_01/appdev.101/b10795/adfns_re.htm
In SQL Server the PATINDEX is used for simple cases and there is no built in Regular Expressions, but you can add it using CLR as shown in this link http://msdn.microsoft.com/en-us/magazine/cc163473.aspx
[Personal Site] [Blog] [Facebook] -
Newbie - need help with a SQL query for a bar chart
Hi,
I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
select null link
, CATEGORY label
, count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
, count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
, count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
, count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
, count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
from GRAPO_PROHEADTRK
where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
group by CATEGORY
Order by COUNT(PROJECT_ID) DESC
The code from the other app was:
select null link
, FUNCTIONAL_AREA label
, count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
, count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
, count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
, count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
, count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
, count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
from PM_V2
where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
group by FUNCTIONAL_AREA
Order by COUNT(PROJECT_ID) DESC
I'm getting a "Failed to parse SQL query!" error when I try to run validation.
Is this enough info for some assistance? Any help would really be appreciated.
Thanks,
RachelHello,
This is more of an SQL question, rather than specifically APEX-related. It's notable that you say: I'm a new user on APEX with no real SQL knowledgeWhich is fine (we all have to start somewhere, afterall) but it might be worth de-coupling the problem from APEX in the first instance. I'd also strongly recommend either taking a course, reading a book (e.g. http://books.google.co.uk/books?id=r5vbGgz7TFsC&printsec=frontcover&dq=Mastering+Oracle+SQL&hl=en#v=onepage&q=Mastering%20Oracle%20SQL&f=false) or looking for a basic SQL tutorial - it will save you a whole lot of heartache, I promise you. Search the oracle forums for the terms "Basic SQL Tutorial" and you should come up with a bunch of results.
Given that you've copied your query template from another, I would suggest ensuring that the actual query works first of all. Try running it in either:
* SQL Editor
* SQL*Plus
* an IDE like SQL Developer (available free from the OTN: http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html ) or TOAD or similar.
You may find there are syntax errors associated with the query - it's difficult to tell without looking at your data model.
select null link
, CATEGORY label
, count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
, count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
, count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
, count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
, count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
from GRAPO_PROHEADTRK
where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
group by CATEGORYNote that your "order by" clause references a field called "PROJECT_ID", which exists in the old query but you've changed other similar references to "PROJECT_STATUS" - is it possible you've just missed this one? The perils of copy-paste coding I'm afraid... -
CREATE TABLE PMS_EMPLOYEE
EMPLOYEECODE VARCHAR2(15 BYTE) NOT NULL
, NAME VARCHAR2(100 BYTE)
, DEPARTMENTCODE VARCHAR2(10 BYTE)
, CONSTRAINT PK_PMS_EMPLOYEE PRIMARY KEY
, EMPLOYEECODE
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 3145728
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05611','Khan','01');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05612','chan','02');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05613','tina','03');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05614','bety','04');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05615','brad','04');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05616','kuty','03');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05617','rose','02');
Insert into PMS_EMPLOYEE (EMPLOYEECODE,NAME,DEPARTMENTCODE) values ('05618','jack','01');
CREATE TABLE PMS_DEPARTMENT
DEPARTMENTCODE VARCHAR2(10 BYTE) NOT NULL
, DESCRIPTION VARCHAR2(50 BYTE)
, CONSTRAINT PK_PMS_DEPARTMENT PRIMARY KEY
, DEPARTMENTCODE
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
Insert into PMS_DEPARTMENT (DEPARTMENTCODE,DESCRIPTIOND) values ('01','HR');
Insert into PMS_DEPARTMENT (DEPARTMENTCODE,DESCRIPTIOND) values ('02','IT');
Insert into PMS_DEPARTMENT (DEPARTMENTCODE,DESCRIPTIOND) values ('03','MA');
Insert into PMS_DEPARTMENT (DEPARTMENTCODE,DESCRIPTIOND) values ('04','FN');
CREATE TABLE TAS_EMPBOOKINGS
EMPLOYEECODE VARCHAR2(10 BYTE) NOT NULL
, TRXTYPE VARCHAR2(2 BYTE)
, TRXDATE DATE
, TRXTIME FLOAT(126)
, CONSTRAINT PK_TAS_EMPBOOKINGS PRIMARY KEY
EMPLOYEECODE
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 233832448
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05611','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),6.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05611','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),15.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05612','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),7.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05612','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),10.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05612','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),12.36);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),7.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),10.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),12.25);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),13.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),13.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05613','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),14.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),7.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),10.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),12.25);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),13.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),13.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),15.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05614','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),15.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05615','IN',to_timestamp('24-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),11.16);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05616','IN',to_timestamp('24-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),10.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05616','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),8.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05617','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),7.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05617','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),12.30);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05617','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),14.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05618','IN',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),7.00);
Insert into TAS_EMPBOOKINGS (EMPLOYEECODE,TRXTYPE,TRXDATE,TRXTIME) values ('05618','OU',to_timestamp('25-JAN-11 00.00.00.000000000',
'DD-MON-RR HH24.MI.SS.FF'),16.30);
I need to count the number of employees inside the office in each department wise.
In case of employee 05611 he is In and out - no count
In case of employee 05612 he is In,out and In - need to count him as he is in at 12.36 still inside the office.
In case of employee 05613 he is In,out,In,out and In - need to count him as he is in at 14.16 still inside the office.
In case of employee 05614 he is In,out,In,out and In - need to count him as he is in at 15.16 still inside the office.
In case of employee 05615 he is In at yesterday but still in the office - need to count him as he is in at 11.16. Query should bring today and previous day
employee who are still inside the office in each department.
In case of employee 05616 he is In and out - in was 24 jan and out at next day so no count.
In case of employee 05617 he is In,out and In - need to count him as he is in at 14.00 still inside the office.
Note: Here they can swipe the card multiple times in or out. we need to find the last swipe in and last swipe out to make them countable and not countable.
In this sample data my output should be like this
Here don't show the Department if the count is 0 (no employee are inside the office) only count greater or equal to 1.
Our output case dept HR will not be shown in output data
Description(that is DepartmentName) InCount
02 2 ( as both chan and rose are inside the office need to count)
03 1 ( tina is in and kutty out. need to count tina only )
04 2 ( as both betty and brad are inside the office need to count then but brad was inside the office from
yesterday not gone out we need to consider him in the count as well)
if the create or insert does not run please correct it and then run.
ThanksNote the name of this forum is SQL Developer *(Not for general SQL/PLSQL questions)* (so only for issues with the SQL Developer tool). Please post these questions under the dedicated SQL And PL/SQL forum (you've posted there before).
Regards,
K. -
Hi team,
Please help me on below query,
I have table like given below
Tran_Id tran_date amount. Actorid
1. 10-apr-15. 100. 1
2. 11-apr-15. 100. 1
3. 11-apr-15. 900. 1
4. 12-apr-15. 100. 1
5. 13-apr-15. 350. 1
6. 14-apr-15. 400. 1
Now please find the query,
I want all the actor ids whos tran amount
>1500 and the date when the tran amount
Has breached
Ex:
Actor-id. Breached-date. Total
1. 13-apr-15. 1900
How can I write a query for above requirement?
Regards,
RajendraYour solution (same as Saubhik's) is incorrect. Look at source data - multiple transactions can occur same day. Therefore, your qury will return wrong results if breached amount is 1000:
with trans as (
select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
trans_running_tot as (
select tran_id, tran_date,
sum(amount) over (partition by actorid order by tran_date) tot_amt, actorid
from trans
trans_ranked as (
select actorid,tran_id, tran_date,
rank() over (partition by actorid order by tot_amt) rk
from trans_running_tot
where tot_amt > 1000
select * from trans_ranked where rk=1
ACTORID TRAN_ID TRAN_DATE RK
1 2 11-APR-15 1 -- here total amount was only 200
1 3 11-APR-15 1
2 8 13-APR-15 1
SQL>
As you can see, 2 rows were returned for actor 1. Why? Default for analytic ORDER BY is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. Therefore, all rows with same transation_date will fall into same window:
SQL> with trans as (
2 select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
3 select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
4 select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
5 select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
6 select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
7 select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
8 select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
9 select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
10 select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
11 select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
12 )
13 select tran_id, tran_date,
14 sum(amount) over (partition by actorid order by tran_date) tot_amt, actorid
15 from trans
16 /
TRAN_ID TRAN_DATE TOT_AMT ACTORID
1 10-APR-15 100 1
2 11-APR-15 1100 1
3 11-APR-15 1100 1
4 12-APR-15 1200 1
5 13-APR-15 1550 1
6 14-APR-15 1950 1
7 12-APR-15 300 2
8 13-APR-15 1500 2
9 14-APR-15 1800 2
10 15-APR-15 2100 2
10 rows selected.
SQL>
So correct solution is to ORDER BY transation id. Also, just in case if amount can be 0, we should add tranaction id when ordering by sum:
with trans as (
select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
trans_running_tot as (
select tran_id, tran_date,
sum(amount) over (partition by actorid order by tran_id) tot_amt, actorid
from trans
trans_ranked as (
select actorid,tran_id, tran_date,
rank() over (partition by actorid order by tot_amt,tran_id) rk
from trans_running_tot
where tot_amt > 1000
select * from trans_ranked where rk=1
ACTORID TRAN_ID TRAN_DATE RK
1 3 11-APR-15 1
2 8 13-APR-15 1
SQL>
SY. -
Where to find the timeout setting for connecting to SAP Bi Universe in Power Query for Excel
Hi All,
I am trying to connect a SAP BI Universe. I am able to login to the environment and get the list of folders. But on trying to use the universe inside the folder, I am getting a time out error. The time out happens exactly at 100 seconds always.
DataSource.Error: SapBusinessObjects: The operation has timed out
Can you let me know if any setting can be done to avoid this timeout and get the universe into power query?I have the same problem with Version: 2.17.3850.242. It times out after 100 seconds.
In addition, I couldn't report it by sending a frown. Get the following error message
Error Message: Could not load file or assembly 'Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
or one of its dependencies. The system cannot find the file specified. -
Power Query for Excel - RSS Feeds
Hi All,
Is it possible to use Power Query to pull RSS feeds into Excel
Thanks
RossHi,
Of course :
And after some changes :
++
Business Intelligence Consultant - Microsoft Certified MCITP, MCTS, MCSA & MVP SQL Server - Data and Big Data fan ! -
Need Help with Oracle Designer Install!
When I attempt to install Oracle designer, it asks me to choose an Oracle Home. I choose "OraHome81" from the drop down menu, but it gives me the following error:
"The location specified: C:\Oracle\Ora81 is already used as an Oracle Home for 'Oracle 815 Production'
It can not be used as an Oracle Home for 'nt' "
PLEASE HELP!!!
my email address is [email protected]As you would have seen if reading the documentation, this is probably a DB home, in which you cannot/should not install Designer. Type another name in there....
....when you are done reading your install guide. -
Executing the saved query for views -Need Help
How can i run get the query for the saved search in views and execute it to view the results ?Can some one help on this pl
Thanks!Hi,
I am not able to get your requirement. Share in little details.
As of my understanding, you want to get the query which is being executed.
Regards,
Gyan -
Looking for suggestion/idea/help WITH T-SQL
Hi all,
The scenario I have is a person can have one or more charges on his/her case.
One charge could be adjudicated as GUILTY and the other charge
is DROPPED. If this is the scenario, I would like to assign GUILTY Adjudication to this case.
OR
One charge could be WITHHELD and the other charge is DROPPED.
If this is the scenario, I would like to assign WITHHELD to this case.
Under Adjudication column, I would like to see GUILTY for case number 12345 and WITHHELD for case 98765
Sample data:
Case Number Charge Charge
Adjudication
Disposition
========== ====== ===========
============
12345 DUI
GUILTY
12345 Driving w/o license DROPPED
98765 DUI
WITHHELD
98765 Driving w/o license DROPPED
Below is the query that returned the above sample Charge Disposition. I am thinking of using CASE expression to determine Adjudication but not sure.
Thank you for everyone's help!
declare @Begindate datetime--
declare @Enddate datetime
set @begindate = '05/01/2014'
set @Enddate = '05/31/2014'
SELECT
(CASE
WHEN cc1.ProsecutorFinalAction IN ('L','O','R') AND
(cc1.ProsecutorFinalDecisionDate >= @BeginDate) AND
(cc1.ProsecutorFinalDecisionDate < DateAdd(d, 1, @EndDate))
THEN pfa1.Description
WHEN (cc1.CourtDecisionDate >= @BeginDate)AND
(cc1.CourtDecisionDate < DateAdd(d, 1, @EndDate))
THEN dbo.fnGetLookupDescription(cc1.CourtActionTaken,'CourtActionTaken')
END)
FROM tblCase c1 with(nolock)
INNER JOIN tblCaseCharge cc1 with(nolock)
ON c1.caseid = cc1.caseid
LEFT OUTER JOIN tblProsecutorFinalAction pfa1 WITH(NOLOCK)
ON cc1.ProsecutorFinalAction = pfa1.ProsecutorCode
WHERE c1.CaseID = @CaseIDIf you want to return just one row for each case, then:
;with cte as (SELECT *, ROW_NUMBER() over (PARTITION BY case_number
ORDER BY case [Charge Disposition] WHEN 'GUILTY' then 1 WHEN 'WITHHELD' ELSE 3 END) AS RN
FROM CasesInfo)
SELECT * FROM cte WHERE Rn = 1 -- will select rows with GUILTY status or WITHHELD status
and not dropped status
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Help with oracle sql to get all possible combinations in a table.
Hello guys I have a small predicatement that has me a bit stumped. I have a table like the following.(This is a sample of my real table. I use this to explain since the original table has sensitive data.)
CREATE TABLE TEST01(
TUID VARCHAR2(50),
FUND VARCHAR2(50),
ORG VARCHAR2(50));
Insert into TEST01 (TUID,FUND,ORG) values ('9102416AB','1XXXXX','6XXXXX');
Insert into TEST01 (TUID,FUND,ORG) values ('9102416CC','100000','67130');
Insert into TEST01 (TUID,FUND,ORG) values ('955542224','1500XX','67150');
Insert into TEST01 (TUID,FUND,ORG) values ('915522211','1000XX','67XXX');
Insert into TEST01 (TUID,FUND,ORG) values ('566653456','xxxxxx','xxxxx');
"TUID" "FUND" "ORG"
"9102416AB" "1XXXXX" "6XXXXX"
"9102416CC" "100000" "67130"
"955542224" "1500XX" "67150"
"915522211" "1000XX" "67XXX"
"566653456" "xxxxxx" "xxxxx" The "X"'s are wild card elements*( I inherit this and i cannot change the table format)* i would like to make a query like the following
select tuid from test01 where fund= '100000' and org= '67130'however what i really like to do is retrieve any records that have have those segements in them including 'X's
in other words the expected output here would be
"TUID" "FUND" "ORG"
"9102416AB" "1XXXXX" "6XXXXX"
"9102416CC" "100000" "67130"
"915522211" "1000XX" "67XXX"
"566653456" "xxxxxx" "xxxxx" i have started to write a massive sql statement that would have like 12 like statement in it since i would have to compare the org and fund every possible way.
This is where im headed. but im wondering if there is a better way.
select * from test02
where fund = '100000' and org = '67130'
or fund like '1%' and org like '6%'
or fund like '1%' and org like '67%'
or fund like '1%' and org like '671%'
or fund like '1%' and org like '6713%'
or fund like '1%' and org like '67130'
or fund like '10%' and org like '6%'...etc
/*seems like there should be a better way..*/can anyone give me a hand coming up with this sql statement...mlov83 wrote:
if i run this
select tuid,fund, org
from test01
where '100000' like translate(fund, 'xX','%%') and '67130' like translate(org, 'xX','%%');this is what i get
"TUID" "FUND" "ORG"
"9102416AB" "1XXXXX" "6XXXXX"
"9102416CC" "100000" "67130"
"915522211" "1000XX" "67XXX"
"566653456" "xxxxxx" "xxxxx"
"9148859fff" "1XXXXXX" "X6XXX" the last item should be excluded. The second digit in "org" is a "7" Fund is wrong, too. You're looking for 6 characters ('100000'), but fund on that row is 7 characters ('1XXXXXX').
and this is sitll getting picked up.That's why you should use the _ wild-card, instead of %
select tuid, fund, org
from test01
where '100000' like translate (fund, 'xX', '__')
and '67130' like translate (org, 'xX', '__')
;It's hard to see, but, in both calls to TRANSLATE, the 3rd argument is a string of 2 '_'s. -
Hi,
In the code below, After a Bulk Insert, i tried to include an UPDATE statement(shown in Italics below) which will update a table . Then I received error. This code will work fine with that UPDATE statement. What do i need to change in the syntax to make this UPDATE statement work?
DECLARE TYPE ename_type IS TABLE OF VARCHAR2(15) INDEX BY PLS_INTEGER;
v_ename ename_type;
BEGIN
SELECT emp.ename BULK COLLECT INTO v_ename FROM emp;
FORALL i IN 1..v_ename.count
INSERT INTO TESTENAME VALUES(v_ename(i));
UPDATE DEPT SET LOCATION='NY';
END;
/I am sorry. I managed to solve this problem. It was a typo.
Maybe you are looking for
-
Cannot open project: the folder for this project cannot be found cs4
I am using Encore CS4 and I get the error "cannot open project: the folder for this project cannot be found" Having searched the forums I can not find a solution for when the project folder has been deleted. Can someone tell me the solution to this
-
Analysis of DV vs. Component Beta-SP on 10-bit timeline
Alright, this may not be the most scentific experiment, but last week I started using a Blackmagic decklink extreme PCIe card with a new G5 dual 2G and FCP5. Importing Beta-SP. Had been accustomed to bumping Beta-SP to DV and working completely withi
-
ADE stuck on cover page and does not go to any page
ADE stuck on cover page and does not go to any page
-
Please help in this code..
Hi, I am developing one small program. Which has one inner class in parent class. I am using object [] array of that inner class. like thisPreferredRoomsItem maxPercentagePrefRooms[] = new PreferredRoomsItem[solutionOfTimeTable.MAX_ACTIVITIES];
-
I have tried to purchase Adobe Edge animate CC 2014. But I can't find any site for purchaing? Where can I find it to buy? I have searched single product, Should I buy with cloud membership?