Please explain this SQL output
1* SELECT style, window, TO_CHAR(rate, '999,999.99') rate FROM ship_cabins ORDER BY 1,2
SQL> /
STYLE WINDOW RATE
--------------- ---------- -----------
Stateroom None 555.65
Stateroom Ocean 5,000.00
Stateroom Ocean 500.00
Suite None 300.00
Suite None 25.00
Suite Ocean 333.44
Suite Ocean 444.55
Suite Ocean 123.78
Suite Ocean 666.66
9 rows selected.
SELECT style, window, rate FROM ship_cabins
WHERE style= 'Suite' AND NOT window = 'Ocean' OR rate > 500;
SQL> /
STYLE WINDOW RATE
--------------- ---------- ----------
Suite None 300
Stateroom Ocean 5000
Suite None 25
Stateroom None 555.65
Suite Ocean 666.66
How can we get the lines withrate <= 500
?How can we get the lines with
window = 'Ocean'
?Published by: 957072 on April 4, 2013 04:23
Hello
957072 wrote:
1* SELECT style, window, TO_CHAR(rate, '999,999.99') rate FROM ship_cabins ORDER BY 1,2 SQL> / STYLE WINDOW RATE --------------- ---------- ----------- Stateroom None 555.65 Stateroom Ocean 5,000.00 Stateroom Ocean 500.00 Suite None 300.00 Suite None 25.00 Suite Ocean 333.44 Suite Ocean 444.55 Suite Ocean 123.78 Suite Ocean 666.66 9 rows selected. SELECT style, window, rate FROM ship_cabins WHERE style= 'Suite' AND NOT window = 'Ocean' OR rate > 500; SQL> / STYLE WINDOW RATE --------------- ---------- ---------- Suite None 300 Stateroom Ocean 5000 Suite None 25 Stateroom None 555.65 Suite Ocean 666.66
OR meanis includes the lines if they meet either the conditon before the OR keyword, or condition that comes after it.
How can we get the lines with
rate <= 500
?
These lines meet the other condition: NO window = "Ocean."
How can we get the lines with
window = 'Ocean'
?
These lines satisfy the condition else: rates > 500
If you want lines that meet all the criteria, then use AND place where.
If you want to use both AND and OR in the WHERE clause even, use parentheses to indicate clearly who will be evaluatd forst.
For example:
WHERE ( style = 'Suite'
AND NOT window = 'Ocean'
)
OR rate > 500
Tags: Database
Similar Questions
-
Hi all
Select col1, col2, col3, col4, col5, col6, count (*), grouping_id (col1, col2), grouping_id(col3,col4), grouping_id (col5, col6) of the Group FLAT_FILE_TEST of grouping sets (col3, col4), ((col1,col2) (col5, col6));
Separate Grouping_id here is 0 and 3
0 is for the current group, other grouping_id become 3.
Someone please explain meaning of 3
Why returning 3?
Thank you
Elayaperumal S
Hello
Thanks for posting the sample data. I get errors on all directions of INSERTION, because the column names aren't the names of columns in the CREATE TABLE statement.
Don't forget to post the results you want from these data, as well as an explanation of how you can (not necessarily how Oracle will be) the results of these data.
Maybe you have nothing particular in mind; you're just experimenting GROUPING_ID to see how it works.
In this case, if I have not answered your question in my first answer, so I understand not what is your question.
In general terms,.
GROUPING_ID (x_n,... x_2, x_1, x_0) equals
(GROUPING (x_n) * POWER (2, n)) +.
...
(GROUPING (x_2) * POWER (2, 2)) +.
(GROUPING (x_1) * POWER (2, 1)) +.
(GROUPING (x_0) * POWER (2, 0))
If you have any questions, please tell what it is. For example "on lines where gro1 = 7, why is - this 7 and not 4? Instead of theis... in language SQL manual it says... and you said... so I expect gro1 to 4 because... «,.
GROUPING_ID is so intimately linked to the GROUPING, then, in your result set, include GROUPING (x), where x is any column that you use as an agrument to GROUPING_ID, for ease of understanding.
-
Please explain this part of the code
CREATE OR REPLACE PROCEDURE IS abc123
-Statements
v_T_MAP_record T_MAP_map % ROWTYPE;
TYPE t_element_cursor IS REF CURSOR;
v_T_MAP_cursor t_element_cursor;
number of v_T_MAP_count;
BEGIN
DBMS_OUTPUT. ENABLE (1000000);
v_T_MAP_cursor: = get_T_MAPs (1308); -This will get the record of the cursor
-Open the cursor
EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;
V_T_MAP_cursor % FOUND LOOP
dbms_output.put_line ('uc.use_case_id: ' | v_T_MAP_record.use_case_id);
v_T_MAP_count: = v_T_MAP_count + 1;
EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;
END LOOP;
-Close the cursor
CLOSE V_T_MAP_cursor;
EXCEPTION
While OTHERS THEN
dbms_output.put_line ('Error' |) TO_CHAR (SQLCODE) | ': ' || SQLERRM);
END;
I do not understand why we are having 2 game instruction Fetch IN v_T_MAP_record's first before the while loop v_T_MAP_cursor and the other inside the v_T_MAP_cursor. Please explain. If I remove the second instruction fetch inside the loop, it gives me a buffer overflow error.It's what he does...
CREATE OR REPLACE PROCEDURE abc123 IS --Variable declarations v_T_MAP_record T_MAP_map%ROWTYPE; TYPE t_element_cursor IS REF CURSOR; v_T_MAP_cursor t_element_cursor; v_T_MAP_count number; BEGIN DBMS_OUTPUT.ENABLE(1000000); -- THIS ISN'T REALLY NEEDED -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself) v_T_MAP_cursor := get_T_MAPs(1308); -- This fetches the first record from the cursor FETCH v_T_MAP_cursor INTO v_T_MAP_record; -- If a record is found we enter a loop WHILE v_T_MAP_cursor%FOUND LOOP -- output the current record details dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id); v_T_MAP_count := v_T_MAP_count + 1; -- fetch the next record FETCH v_T_MAP_cursor INTO v_T_MAP_record; -- loop back to the start of the while loop END LOOP; --Close the cursor CLOSE v_T_MAP_cursor; -- Pointless stupid exception handler EXCEPTION when OTHERS THEN dbms_output.put_line('Error ' || TO_CHAR(SQLCODE) || ': ' || SQLERRM); END;
Although this would be a better style:
CREATE OR REPLACE PROCEDURE abc123 IS --Variable declarations v_T_MAP_record T_MAP_map%ROWTYPE; TYPE t_element_cursor IS REF CURSOR; v_T_MAP_cursor t_element_cursor; v_T_MAP_count number; BEGIN -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself) v_T_MAP_cursor := get_T_MAPs(1308); LOOP -- This fetches the first/next record from the cursor FETCH v_T_MAP_cursor INTO v_T_MAP_record; EXIT WHEN v_T_MAP_cursor%NOTFOUND; dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id); v_T_MAP_count := v_T_MAP_count + 1; END LOOP; --Close the cursor CLOSE v_T_MAP_cursor; END;
However, I would also change things to use the SYS_REFCURSOR as the need to define your own type from the REF CURSOR was placed back in 9i with the new type built in SYS_REFCURSOR.
There are probably many other things I would like examine why I'm using ref Cursor in the first place and why I try to write data using dbms_output etc., but hey, we all have start somewhere.Published by: BluShadow on 28-Sep-2012 14:28
-
Hello
I'm prerparing to SCJP.
I got this question
What will be the result of the program?
{public}
public static throwit Sub)
{
System.out.Print ("throwit");
throw new RuntimeException();
}
Public Shared Sub main (String [] args)
{
Try
{
System.out.Print ("hello");
throwit();
}
catch (Exception)
{
System.out.Print ("taken");
}
Finally
{
System.out.Print ("finally");
}
System.out.println ("after");
}
}Hello throwit caught
Compilation failure
Hello throwit RuntimeException captured after
Hello throwit finally after
What is treatment and why. Please explain
answer would be D.
car-
The method main() correctly handles the RuntimeException in the catch block catch finally runs (as it always does), and then the code returns to normal.
A, B, and C are incorrect based on the logic of the program described above. Don't forget that properly handled exceptions do not cause the program to stop execution.
-
SQL: can someone please explain this question?
Select to_char (-4567, ' 9999 mI') a1, to_char (-4567, '99999pr') n2, to_char (4567, '00099999') double a3
Select to_char (4567, '9.999EEEE') a1, to_char (4567, '9999V9999') double n2
--
Thank you
You need to consider the Format of number patterns
http://docs.Oracle.com/database/121/SQLRF/sql_elements004.htm#SQLRF00211
-
Can someone please explain this to me
So yesterday, I made a change in our production database. What we had was a synonym in the S1 schema that pointed to a view of schema S2. We needed to make a change to do some minor data manipulations before we see in S1. So I dropped the synonym and created a view of the same name. All this went well in dev and QA, where we register S1 to do all the tests, but in production, our application connects to the database as S1USER that has select privileges on all tables of S1 and the views. After you have created the user view privileges granted DBA select on view at S1USER, but when I tried to query the table like S1USER I got ORA-01031: insufficient privileges. The DBA has thought that I didn't select privileges on the underlying view in S2, so it has that. Again I got the error of insufficient privileges. He seems to have had the privilege to choose granted by the account DBA was not good enough, he had to be granted by S1. I have never heard something like that. Why don't the DBA grant select to do the job, and select should be granted by the owner of the schema. Someone at - he never encountered this before?
Even if ADMINISTRATOR privilege, he did on behalf of S1, considered as a DBA user:
SQL > grant create session to one identified by one;
Grant succeeded.
SQL > grant select on mpprod.indv_t to one.
Grant succeeded.
SQL > select table_name, constituent
2 of dba_tab_privs
3 where dealer = "A";TABLE_NAME GRANTOR
------------------------------ ------------------------------
INDV_T MPPRODHowever, nor the role of s/n, not the DBA have with grant on the indv_t table option, the ADMINISTRATOR cannot transmit the (implicit) permissions on the table S2 S1 at S1user. Only S1 can transmit the implicit permissions to table S2.
John
-
I take the test and found this code-
public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }
public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 10
}
}The following code fragments inserted, for compiling?
A. New inner(); On line 5 B. New inner(); On line 10 C. OT again. Inner(); On line 10 D. new Outer.Inner (); On line 10 Answer is A.
Why not the answer is B?
well explained by cardan2
further explanation
Option A compile without problem
Option B gives an error - variable not static cannot be referenced from a static context.
There is no option package C only ot.
Option D gives an error - variable not static cannot be referenced from a static context.
hope you get it
-
This message keeps popping up... does that mean?
Set WshShell = CreateObject ("WScript.Shell")Chr (34) WshShell.Run & "C:\Program Files\Verizon\IHA_MessageCenter\Temp\Start_SVC.bat" & Chr (34), 0Set WshShell = NothingThis message keeps popping up... does that mean?
Set WshShell = CreateObject ("WScript.Shell")Chr (34) WshShell.Run & "C:\Program Files\Verizon\IHA_MessageCenter\Temp\Start_SVC.bat" & Chr (34), 0Set WshShell = Nothinghttp://msdn.Microsoft.com/en-us/library/d5fk67ky%28V=vs.84%29.aspx
potentially, this could be a useless program / unwanted...
-
Level - Can Reporting someone please explain this attribute?
All - I am a newbie on Siebel on demand but creating reports with other tools for years. I recently came across some reports that I inherited that constantly give us bad. These are basic reports that look at the number of calls, meetings, etc. for a given user. What we see is that we used this statement attribute level to filter, but according to the Manager of logging level in it cause problems. Some people cannot see the data, and some receive a massive amount of duplicated data.
When all is said and done, we are looking for a simple list of Manager-rep of counts of these activities. After looking at the value of level reporitng it would look like an indicator of the relative position of the level lower in the reports - to the hierarchy. We will generally filter level = 0 (or maybe 1) reports more but what I want is a way to control based on the user. My requirement is to have the level they can see and retail at a level more low but I don't ' fully understand how that is created or how can I use system variables to determine the level of user control.
Anyone who has the news of background on this page or how I can order a basic report anaylytic in more manageable to show my stuff and subtotals to a level more down which would be greatly appreciated.Not sure if I can help with the specific report, but I'll try more of light level Reporting.
In a report which is flush with the dimension possessed by the user, you can find the Reporting level field. Each user belongs to a reporting hierarchy, derived from the "Reports To" value in their user profile.
The best way to see it is to create a simple report with the Email of the user level reports and email Manager. This will show you the Manager at each level. You can use this to expose and filter on the complete management hierarchy.
Level 0 = user. All users have a value of themselves as Manager at level 0.
Level 1 = reports to-which reports directly to the user.
Level 2 + = towards the top of the chain...You can take a look at some of the predefined reports to see how this can be used to create reports based team, as 'Team Pipeline Analysis', ' team sales analysis of efficiency "and"analysis of the Team activity. You can open all the pre-buiilt reports as well as the starting points.
-
Can you please explain this grace of Scripts
Cat /oracle/data/XXX/Headcount.txt $HADOOP/other/chrtacct.dim > /oracle/data/XXX/chrt3.txt
Cat /oracle/data/XXX/invgp5.txt /oracle/data/XXX/Headcount.txt $HADOOP/other/chrtacct.dim > /oracle/data/XXX/chrt2.txt
Cat $HADOOP/XXX/shc_busform.dim $HADOOP/other/altbfmt.dim > /oracle/data/XXX/bsfrmdim.txt
Cat /oracle/data/XXX/UDA.txt > /oracle/data/XXX/KUDA.txt
##############################################################cat is to concatenate the files listed on the left of the ">" symbol and direct the result in the file on the right of the ' > ' symbol (which will be overwritten if it already exists).
Type "cat man" on your system to learn more about how it works.
-
Please convert this SQL ORALCE code
Select the title
cases where there is right (title, 2) = 12 then cast (left(title,2) + 1 varchar (2)) + cast ('01' as varchar (2))
another title + 1 end next_title,
cases where right(title,2) = '01' then cast (left(title,2) - 1 varchar (2)) + cast ('12' as varchar (2))
another title - 1 end prev_title
of strdc_admin.st_glt_shipment
Group by title
title sequenceIf the title is of type VARCHAR2:
SELECT title, CASE WHEN SUBSTR(title, -2) = 12 THEN TO_CHAR(TO_NUMBER(SUBSTR(title, 2) + 1)) || '01' ELSE TO_CHAR(TO_NUMBER(title + 1)) END AS next_title, CASE WHEN SUBSTR(title, -2) = 12 THEN TO_CHAR(TO_NUMBER(SUBSTR(title, 2) - 1)) || '12' ELSE TO_CHAR(TO_NUMBER(title - 1)) END AS prev_title FROM strdc_admin.st_glt_shipment GROUP BY title ORDER BY title
URS
-
Please explain 1/24/3 600 s
Can you please explain this SQL I was running with 24/1/3600. What is this way with regard to the last day of the month. Thank you
-- Revenue Recognition date within the previous month AND ob.revenue_recogn_date BETWEEN (LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE), -2)) + 1) AND (LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE), -1)) + 1 -1/24/3600)
ricard888 wrote:
What does the logic here in terms of revenue capture.As it says in the commentary:
-Date of recognition of income in the previous month
It limits the selected lines in the rows where ob.revenue_recogn_date is the last month (e.g.within July if you run today and inside August when you launched it in September).
SY.
-
Please explain the difference between the sql data
Please explain the difference of next sql
Select emp. ID, Dept. DeptName from Employee emp
Join (select DeptId, DeptName Department where deptId = 2) dept on emp.deptId = dept.deptId
Select emp. ID, Dept. DeptName
employee emp
inner join Department dept
on emp. DeptId = Dept. DeptId
where Dept. DeptId = 2
two of them provide the same results, but what is the good? Is there a difference... Does this affect performance
What is the best way of writing
Thank you
Published by: user8708731 on August 30, 2011 11:02
published the first query to select only Deptname
Published by: user8708731 on August 30, 2011 11:12select emp.Id, dept.DeptName from Employee emp join (select DeptName, DeptId from Department where deptId = 2 ) dept on emp.deptId = dept.deptId all Employee rows are joined to filtered Department rows (a single row or no rows) matching deptIds are retained and make their way to the result select emp.Id, dept.DeptName from Employee emp inner join Department dept on emp.DeptId = dept.DeptId where dept.DeptId = 2 all Employee rows are joined to all Department rows matching deptIds are retained and filtered dept.deptIds make their way to the result
Concerning
Etbin
-
Please help me with this SQL query
I'm practicing of SQL queries and met one involving the extraction of data from 3 different tables.
The three paintings are as below
< pre >
Country
Location_id country
LOC1 Spain
loc2 England
LOC3 Spain
loc4 USA
loc5 Italy
loc6 USA
loc7 USA
< / pre >
< pre >
User
user_id location_id
loc1 U1
loc1 U2
loc2 U3
loc2 U4
loc1 U5
U6 loc3
< / pre >
< pre >
Publish
user_id post_id
P1 u1
P2 u1
U2 P3
P4 u3
P5 u1
P6 u2
< / pre >
I am trying to write a SQL query - for each country of the users, showing the average number of positions
I understand the logic behind all this that we must first consolidate all locations, and then the users in one country and then find the way to their positions.
But, I'm having a difficulty to this format SQL. Could someone help me please with this request.
Thank you.Select
Country.Country,
Count (*) Totalpostspercountry,
Count (distinct post.user_id) Totaldistincuserspercountry,
count (*) / count (distinct post.user_id) Avgpostsperuserbycountry
Of
countries, have, post
where country.location_id = muser.location_id
and muser.user_id = post.user_id
Country.country groupThe output is like this for your sample data - hope that's what you're looking for :)
COUNTRY, TOTALPOSTSPERCOUNTRY, TOTALDISTINCUSERSPERCOUNTRY, AVGPOSTSPERUSERBYCOUNTRY
In England, 1, 1, 1.
Spain, 5, 2, 2.5. -
I have an error in my event viewer: the fault bucket + 45216 0xD1_athr, type the name of the event 0: BlueScreen
Can someone please explain to me how to solve this problem. My computer shuts down whenever I get on the internet. I need some answers please.
You have a problem with a driver Atheros.
It could be the network card is bad or the driver is damaged.
If it is a wireless card, try to connect to the router with an ethernet cable. See if you can get an updated driver from the computer manufacturer's website.
http://msdn.Microsoft.com/en-us/library/ff560244 (v = VS. 85) .aspx
Maybe you are looking for
-
Satellite A505 wake mode standby automatically
I usually just close the lid on my Satellite A505 when I actually use it for a while, in order to put him to sleep, to rest it and save energy. However, I often find that for some reason, he wakes up on his own.I find with the cover still down, but f
-
Agilent 6812 B power cord does not work with the class IVI driver
I try to use a power source Agilent 6812 B with class IVI DISARM on RS232 driver. I have everything set up NI Max but I can't by the initialization routine. I tried in LabView and LabWindows and nor will not work. I decided to follow the lines RS23
-
Where to get service pack 1 XP
I need a version of service pack 1 for xp that I record on another computer because the xp computer has no conn I have-net where can I go to get
-
Connecting Wireless Router WRT160N error message
This is the report on the progress of the errors after the diagnosis of my connection, I received. Everything I tried to do has not solved my problem. Help, please! Thank you Event (class of assistance RNWF MSM) helper class: Wireless Diagnostic Help
-
Site at tunnel breaks on upgrading to 8.3.2
Hello I have a site-to-site (bidirectional) tunnel set up between two ASA 5510 (Headquarters and remote offices) 8.2.2 running. I'm going through one end of the tunnel (Headquarters) to 8.3.2 but when I do it, traffic to headquarters remote desktop i