Why do I get different results of these
I use the HR diagram and study the nested instructions. When I run these two SQL statistics I get a different result. Someone knows why?Select avg (salary), country_id of
(select department_id, location_id, salary, country_id of)
employees join natural services locations of natural join)
Country_id group;
Select avg (salary), country_id (select country_id, treatment)
employees join departments using (department_id)
Join the locations using (location_id))
Country_id group;
Thanks in advance.
Natural join joins the tables on columns with the same name. If you look at HR. EMPLOYEES and human resources. Tables of DEPARTMENTS, they share two columns department_id and MANAGER_ID while your second query attached just the department_id. If you add MANAGER_ID to the second query that both return the same results:
SQL> select avg(salary),
2 country_id
3 from (
4 select salary,
5 department_id,
6 location_id,
7 country_id
8 from hr.employees natural join hr.departments natural join hr.locations
9 )
10 group by country_id;
AVG(SALARY) CO
----------- --
5640 US
6000 CA
8500 UK
SQL> select avg(salary),
2 country_id
3 from (
4 select salary,
5 country_id
6 from hr.employees join hr.departments using(department_id,manager_id)
7 join hr.locations using (location_id)
8 )
9 group by country_id;
AVG(SALARY) CO
----------- --
5640 US
6000 CA
8500 UK
SQL>
SY.
Tags: Database
Similar Questions
-
I use an .exe on two different windows boxes, in Windows 7 and XP. I put both for resolution 1024 x 768.
Win 7 (old laptop and Dell desktop computer) I have a large application to watch. On the WIn XP boxes all fonts to big. It doesn't make sense for me as all PC's have the same resolution.
Has anyone go through this before?
System for XP and Vista/Win7 fonts are different.
See
http://forums.NI.com/T5/LabVIEW/elements-have-moved-when-opening-VI-with-F3-patch/m-p/1054817
and several other similar topics.
-
Get different results even script according to what VM it hits?
Hello.
IM starting to Powershell and PowerCLI, so you will know at what level it is on =)
I get different results depending on what VM my script hits (whetever they may or may not have more than one drive). I do not understand how I can fix this...
For example, I created 4 new virtual machines.
TestVMfirst1 have only a single drive
TestVM02 have 2 drives
TestVM03 have 3 discs
TestVM04 have only a single drive
My goal is to get a CSV with all disks included. I want the name, the data store and SizeGB, this info I get from Get-hard drive.
When I run my script to select all 4 virtual machines:
$VMs = get-cluster-name kluster01 : get-vm-name TestVM *
-----------------------------------------------------------------------------
$VMs = get-cluster-name kluster01 | Get-vm-name TestVM *.
$Results = @)
{foreach ($VM to $VMs)
$Result = new-object PSObject
$Result | Add-Member - membertype NoteProperty-name 'Name' - value $VM. Name
$VMDiskCount = 1
Get-$VM hard drive | {foreach}
$disk = $_
$Result | Add-Member-'Disc ($VMDiskCount) name' name-value $disk. Name - membertype NoteProperty
$Result | Add-Member-name '($VMDiskCount) Datastore disk' - value $disk. Filename.Split(']') [0]. TrimStart('[') - membertype NoteProperty
$Result | Add-Member-name 'Disk ($VMDiskCount) SizeGB' - value ([math]: round ($disk.) CapacityKB / 1 MB))-membertype NoteProperty
$VMDiskCount ++
}
$Results += $Result
}
$Results | Select-object * | format-table
-----------------------------------------------------------------------------
I get the result with max 1 disc:
Name (1) name of disc Disk data store (1) SizeGB disc (1) ---- ----------- ---------------- ------------- TestVMfirst1 Hard drive 1 DS-201 40 TestVM02 Hard drive 1 DS-201 40 TestVM03 Hard drive 1 DS-201 40 But if I run the same thing but with TestVM0 * (selects 4-2 VMs):
$VMs = get-cluster-name kluster01 | Get-vm-name TestVM0 *.
-----------------------------------------------------------------------------
$VMs = get-cluster-name kluster01 | Get-vm-name TestVM0 *.
$Results = @)
{foreach ($VM to $VMs)
$Result = new-object PSObject
$Result | Add-Member - membertype NoteProperty-name 'Name' - value $VM. Name
$VMDiskCount = 1
Get-$VM hard drive | {foreach}
$disk = $_
$Result | Add-Member-'Disc ($VMDiskCount) name' name-value $disk. Name - membertype NoteProperty
$Result | Add-Member-name '($VMDiskCount) Datastore disk' - value $disk. Filename.Split(']') [0]. TrimStart('[') - membertype NoteProperty
$Result | Add-Member-name 'Disk ($VMDiskCount) SizeGB' - value ([math]: round ($disk.) CapacityKB / 1 MB))-membertype NoteProperty
$VMDiskCount ++
}
$Results += $Result
}
$Results | Select-object * | format-table
-----------------------------------------------------------------------------
I get this result:
Name (1) name of disc Disk data store (1) (1) name of the disc SizeGB disc (2). Disk data store (2) SizeGB disc (2) ---- ----------- ---------------- ------------- ----------- ---------------- ------------- TestVM02 Hard drive 1 DS-201 Hard 40 2 disc DS-201 10 TestVM03 Hard drive 1 DS-201 Hard 40 2 disc DS-202 10 TestVM04 Hard drive 1 DS-201 40 I miss all my disks on TestVM03, I seems that the first VM sets the limit on how many records can be issued in the table... A dirty solution is to create a model on the first target VM disks, but it seems the wrong way to solve my problem.
Thanks in advance
You're conclusion is correct, I'm afraid, the first line determines how many properties, you will see.
Alternatively, you can sort the lines on the number of properties in descending order.
Something like that
$Result | Tri-objet-property {($_ |)} Get - Member). {Count of}-descending | Format-Table
-
Why do I get 2 different results of these identical derivatives screws?
I wrote two calculator derived from point by point identical screws and I am at a loss about why
I get two different results. I don't know what I have missed/missing which is the origin of this anomaly.
Please take a look at the downloaded screw (written in LabVIEW 8.0) and let me know what I did wrong.
Perhaps they are not the same after all.
Tips for troubleshooting or suggestions are welcome!
Thank you
noviceLabVIEWuser
item 1 of table 1 = 0.9998899980
item 1 of table 2 = 0.9998900000
Change the format to display the different values
the code is identical
-
using the same search terms on ebay, getting different results on firefox exploer
using the same words to search on ebay for internet explorer, I get results more when I use ebay on FireFox > is cutting some of the results when using Firefox
It is always possible that eBay is to differentiate between browsers and gives different results, based on previous visits.
You can try to delete cookies in two browsers to see if it has an impact."Clear the Cache":
- Firefox/tools > Options > advanced > network > content caching Web: 'clear now '.
'Delete Cookies' sites causing problems:
- Firefox/tools > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".
-
When I concatenate the hexadecimal values of 2 different ways a get different results
When I concatenate 2 strings in "hexadecimal view" the result is what I want. When concatenate [a decimal number converted into a hexagon] with [a string in "Display Hex"] the results is very different. Attached shows the code 2 cases. In my code, why different 'LDD_Command 2' of 'LDD_Command '? Thank you.
The digital conversion to the hex string it gives normal representation (indicator LDD_input) chain. You display in the string with the representation of the hexagon (second part of the command LDD 2), they are not equal.
If I understood you, you need display data (0CCD is hex for 3277 = u16(1/20*65535). If you need to have data with the representation of string - data should not change, expected just the way which display you them. This is done with the type cast.
-
Why am I getting mixed results after expansion direct painting concerning the other paths?
I notice with live paint, most of the time when I develop and disassociate my strokes of my roof, that sometimes the lines are all closed forms because they were originally, and other times they are cut where they cross eachother. At first I thought that the cutting of the path is only occurring where in the live paint group colors were applied to different categories of shapes that overlap...
but in these cases sometimes after expansion/separate, these initial forms are still intact... I can't understand what is the problem...
bluefire777 wrote:
If you create your initial forms as in the road open or closed with traits but NO fill, when you "develop" this live paint group, your footsteps of origin are kept, they will not be cut...
It is simply not true.
It doesn't matter what you enter. The only thing that matters, it's how make you out in the group.
If I take these 3 circles
Do a live paint group
All the features of black paint
And then I get 3 circles
So what you enter is not serious. It takes only the appearance of the "live" version
-
Why did I get this result when I use split
Hello guys
I created a script that are looking for the active path,
var myPath = (File($.fileName).parent.parent.parent.fullName); alert(myPath)
I get "/ xxxxx/xxxx/xxxx/341542 '
the only thing I'm interested in this information, it is the number
so I added the code
var myPath = (File($.fileName).parent.parent.parent.fullName).split("xxxx/xxxx/xxxx/");
the problem is
I get ', 341542'
Why did I receive a comma before the number?
There is no comma. in the path.
Hello
Using the split() method, you receive a table - not a string ==> myPath is an array of 2 elements.
If you are alert a result - he is seen like this, couse of elements of the array are ',' delimited.
To call a number part use myPath [1]
Jarek
-
How to get the result of these data
Hi all
I have a following data. And I need the output as follows.
If one of the Intr_num is missing so I need the output to be formatted the next row.
I tried this using the row_number() but could not able to achieve the result. Is there any other function or analysis features to use.
with t as ( select 10001 id, 5004 Intr_num from dual union all select 10002,5005 from dual union all select 10003,5006 from dual union all select 10004,5007 from dual union all select 10006,5009 from dual union all select 10007,5010 from dual union all select 10010,5013 from dual union all select 10011,5014 from dual union all select 10012,5015 from dual union all select 10013,5016 from dual union all ) select * from t; OUTPUT: Intr_num 5004 - 5007 5009 - 5010 5013 - 5016
Kind regards
SID
Hello
ROW_NUMBER is the right function to use:
WITH got_dif AS
(
SELECT intr_num
, intr_num - ROW_NUMBER () OVER (ORDER BY intr_num) AS dif
T
-WHERE... - If you need any filtering, put it here
)
SELECT MIN (intr_num) | ' - '
|| MAX (intr_num) AS intr_num_range
OF got_dif
GROUP BY dif
ORDER BY dif
;
-
Export PDF get different results if a page or an entire book.
I have a book from a client who was about 200 pages. It comes to calendars and everyone was in a PDF document and placed in InDesign. They had two AD22 pages at a point and changed the second AD23. It previews AD22 in InDesign, unless the high quality display is chosen, then it previews AD23. When I export the entire book, it exports the calendar AD22. When I export this page only exports the AD23. Also when I print this page it prints correctly. I don't understand what is happening, but thousands of pounds are already printed. If someone else has encountered something like that?
Try the .idml
-
Get different search results on different workstations
Can someone give me some insight on why would be the following:
Users A and B on two different workstations - both using the same version of the compiled HTML help find their application type the exact same word and click view. At the user obtains a list of 39 subjects and user B Gets a list of 10 subjects.
I tested it with one of my developers and we have checked that we each entering the same search criteria exact but get different results.
What should we do to ensure that this happens not when we distribute our application? Or at least what we can do to fix for a user when he arrives?
I use RH - HTML X5.0.2
Thank youMark, you're a genius... I am not I never thought to check this.
Thanks for your help.
Pat -
original title: a different output for ping - an IP address
I am trying to determine the name of the computer to an IP address
When I open a command prompt in a computer (Windows XP connected to our domain) and type ping - a [IP address], I get a result
When I open a command prompt in another computer (Windows Server 2008 connected to the WORKING group) and type ping - a [IP address], I get a different result
And there are other times when ping - [IP address] will display the name of the computer on a computer (usually the Windows Server 2008), but not the other
I tried to google
1. why this happens
2. what result is correct
Please specify.
The order of DNS in Windows name resolution is as follows:
- Name of the local host (file Hosts Local generally in c:\windows\system32\drivers\etc\hosts)
- Cache Client DNS resolution
- DNS server
- Cache of NetBIOS names
- WINS server
- NetBIOS broadcasts
- File LMHosts (same location as the HOSTS file)
The reason you get different results could be because machines could be on different subnets (different results for broadcast), using a different DNS server machines or are configured for different WINS servers, or the names are already cached because of prior activity.
HTH,
JW -
List of deployed applications. Different results for different hierarchies of MBean
Hello
When I list deployed applications, I get different results depending on what hierarchy MBean I question:
- serverConfig():
wls:/MY_WEBLOGIC_DOMAIN/serverConfig> listApplications() APPLICATION_1APPLICATION_2
- domainRuntime():
wls:/MY_WEBLOGIC_DOMAIN/domainRuntime/AppRuntimeStateRuntime/AppRuntimeStateRuntime> ls() -r-- ApplicationIds java.lang.String[APPLICATION_1, APPLICATION_2, APPLICATION_3]
No idea why is APPLICATION_3 in the list?
Thanks in advance,
Luis
PS: if I apply directly to the managed server:
wls:/MY_WEBLOGIC_DOMAIN/domainRuntime/ServerRuntimes/prodGAD_1> ls('ApplicationRuntimes') dr-- bea_wls9_async_response dr-- bea_wls_cluster_internal dr-- bea_wls_deployment_internal dr-- bea_wls_diagnostics dr-- bea_wls_internal dr-- APPLICATION_1 dr-- APPLICATION_2
Hi Vijaya,
Thanks for your reply, yes you are right, my config.xml file I see this request:
APPLICATION_3 ... ear ...ear DDOnly But now that I read your response, I already rebooted the AdminServer. This new beginning has resolved the problem.
Thank you
Luis
-
Different results of exactly the same query
Hello
I wrote a function to calculate the days between 2 dates. If I am running in SQL Developer or directly on the oracle server, I get the results I expected. However, if I run on a client by using ODBC, or PHP connection via the OCI8 extension, I get an incorrect result.
The function takes 2 parameters: 1st and 2nd date and should output the number of non-working days (weekends and holidays) between 2 dates. The coding is not very pretty, but it does not work very well as I said since the client SQL Developer.
Here is the code:
The problem is only with certain dates. For example, if I use the date '17-SEP-2012' for the two input parameters, I'm waiting for a result draw. In the SQL Developer client, I get the expected result. However, using ODBC or PHP OCI8 (which I believe is using a direct connection to TNS in the DB), the result returned is '1', which is incorrect ("17-SEP-2012" has been a MONDAY ""). If I use the current date (20-SEP-2012), I get the expected (zero) result in both the SQL Developer client and ODBC/PHP client.create or replace FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE) --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays) --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013 RETURN NUMBER IS BANK_HOLS NUMBER; ret NUMBER; BEGIN SELECT count(mydate) INTO ret FROM (SELECT TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss') - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + 1) WHERE TO_CHAR (mydate, 'DY') IN ('SAT', 'SUN'); select count(mydate) into BANK_HOLS from ( SELECT TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss') - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + 1 ) WHERE TO_CHAR (mydate, 'DD-MM-YYYY') IN ('03-01-2011', '22-04-2011', '25-04-2011', '29-04-2011', '02-05-2011', '30-05-2011', '29-08-2011', '26-12-2011', '27-12-2011', '02-01-2012', '06-04-2012', '09-04-2012', '07-05-2012', '04-06-2012', '05-06-2012', '12-07-2012', '27-08-2012', '25-12-2012', '26-12-2012', '01-01-2013', '29-03-2013', '01-04-2013', '06-05-2013', '27-05-2013', '12-07-2013', '26-08-2013', '25-12-2013', '26-12-2013' ); ret:= ret + BANK_HOLS; RETURN ret; end;
I also tried to use variants of SYSDATE in place and place the date string, to see if I get different results (i.e. today is 20-SEP-2012, so I used SYSDATE-3 to 17-SEP-2012).
To be clear, I call the function in a select statement: select (sysdate-3, sysdate-3) non_workdays of the double; or select non_workdays (TO_DATE('17-SEP-2012'), TO_DATE('17-SEP-2012')) of double;
I have spent hours and hours of troubleshooting this, and it makes me crazy!
I also checked the view V$ SQLAREA the Oracle DB to see what is actually passed to the ODBC client database engine. I was expecting the statement became corrupted somehow, that's why I get strange results, but this was not the case. The statement in the column SQL_FULLTEXT of V$ SQLAREA, showed exactly the statement I performed on the ODBC Client. I tried with the oracle instantclient and full client (10g).
Can someone help save my sanity please? I am eternally grateful!
Sorry for the massive post!
Published by: user12199535 on 20-Sep-2012 12:20Your code is a mess. You convert DATE to DATE, e.g. TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss'). TO_DATE function first parameter is a string, while fromdate is the date. That's why Oracle implicitly converts fromdate to the string of default date format that is client dependent and therefore can produce different results on different customers boxes. In addition, your code is dependent on NLS. If the customer has other date language settings, for example German, Sun and SAT are false. And there is no need to separately calculate the weekends and holidays:
create or replace FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE) --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays) --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013 RETURN NUMBER IS BANK_HOLS NUMBER; ret NUMBER; BEGIN SELECT count(mydate) INTO ret FROM ( SELECT trunc(fromdate) + LEVEL - 1 mydate FROM DUAL CONNECT BY LEVEL < = trunc(todate) - trunc(fromdate) + 1 ) WHERE TO_CHAR(mydate,'DY','NLS_DATE_LANGUAGE = ENGLISH') IN ('SAT','SUN') OR mydate IN ( DATE '2011-01-03', DATE '2011-04-22', DATE '2011-04-25', DATE '2011-04-29', DATE '2011-05-02', DATE '2011-05-30', DATE '2011-08-29', DATE '2011-12-26', DATE '2011-12-27', DATE '2012-01-02', DATE '2012-04-06', DATE '2012-04-09', DATE '2012-05-07', DATE '2012-06-04', DATE '2012-06-05', DATE '2012-07-12', DATE '2012-08-27', DATE '2012-12-25', DATE '2012-12-26', DATE '2013-01-01', DATE '2013-03-29', DATE '2013-04-01', DATE '2013-05-06', DATE '2013-05-27', DATE '2013-07-12', DATE '2013-08-26', DATE '2013-12-25', DATE '2013-12-26' ); RETURN ret; end; /
SY.
P.S. I think that I converted your vacation to literals correctly, but still double check date. -
Two same queries but different results
I'm working on the guarantee of data from data sources Vs target.
Source and target databases are oracle. The source data are a remote database and navigate using DB_LINK.
I am running similar queries against the data source and my schema but gets different results I check the number of folders and individual service Group DC account
both are fit exactly, but for some reason any after the results of queries in different counts.
a request flowing from the source table:
Select
b.Year,
b.month,
a.serv_grp,
Count (distinct a.clnt) cnt
Of
Jay.srvrequest@bdm_link has,
(select separate year, month, first_date_of_month, last_date_of_month)
of dev.stage_3_time_dim
where year = 2011 and
b months between 3 and 7)
where
a.beg_dt < = b.last_date_of_month
and a.end_dt > = b.first_date_of_month
and a.serv_grp in ('1 ', '4', '5',' 6') and
a.stat as 'A '.
B.year group, b.month, a.serv_grp;
target request flowing from the database:
Select
b.Year,
b.month,
a.service_group_cd,
Count (distinct a.client_id) cnt
Of
Prod.stage_0_mg_serv_req has,
(select separate year, month, first_date_of_month, last_date_of_month)
of dev.stage_3_time_dim
where year = 2011 and
b months between 3 and 7)
where
a.begin_dt < = b.last_date_of_month
and a.end_dt > = b.first_date_of_month
and a.service_group_Cd in ('1 ', '4', '5',' 6') and
a.status_cd as 'A '.
B.year group, b.month, a.service_group_cd
results out of data from the source as follows:
Year month serv grp cnt
2011 3 1 78653
2011 3 4 4562
2011 3 5 166
2011 3 6 7533
2011 4 1 78327
2011 4 4 4540
2011 4 5 167
2011 4 6 7546
2011 5 1 78612
2011 5 4 4535
2011 5 5 166
2011 5 6 7544
results off-target following data:
Year month serv grp cnt
2011 3 1 49350
2011 3 4 1921
2011 3 5 26
2011 3 6 2259
2011 4 1 47727
2011 4 4 1834
2011 4 5 27
2011 4 6 2211
2011 5 1 46675
2011 5 4 1771
2011 5 5 26
2011 5 6 2116
I don't know what wrong with queries
any advice appreciated...
JayMaybe you get different results because the data are different.
Also, why the first query uses a remote table, attached to a local table? Why not 100% remote data?
Maybe you are looking for
-
MainStage 3 crashes at opening with macOS Sierra
I just bought 3 MainStage on the App Store and it loaded on my Sierra (Public Beta 2) Mac OS installation, but the app crashes everytime I go to open it. Specific error is: "MainStage 3 quit unexpectedly when you use the libsystem_malloc.dylib plugin
-
Where are stored the photos?
I've just upgraded to the new Macbook with more 5 000 photos (after the ones I don't want the purge). I can't afford to move to an Icloud plan which supports this type of space. So I "disabled and deleted" my photo of Icloud download after having sav
-
I want to be able to delete or archive messages in my Inbox after 120 days? Otherwise, every time I opened my Inbox I'm to half way down and have to scroll for always to the top to read my emails later!
-
Note remains 1/4 length in the partition editor when shortening
Is there a way to see the actual size of the note in the score editor after resizing of the note in the list of events. Now a note remains a certain length...
-
I lost the box on the top of the Firefox page where you type in a URL. At the same time, I have no back or forward buttons. Help please This has happened Just once or twice is tonight