Use the value of the sum and compare
I have a table with data below
T1
ID, amount
12,20
13,10
14.5
create table T1 (ID number, amount);
Insert into T1
Select double 12.20;
Union
Select 13,10 double;
Union
Select double 14.5;
I need the sum of the quantity and the value of the sum compares the values as flat > display then 10 0 otherwise amounted
output
ID, amount, derived
12,20,20
13,10,10
14,5,5
If my table has a
T1
12.0
13.5
It should be
T1
12,0,0
13,5,0
You can use the analytic function SUM
select id, amount, case when sum(amount) over() > 10 then amount else 0 end derived from t1
Tags: Database
Similar Questions
-
I am facing a problem with the beep.vi. I have a DAQ program, which acquired the signal and compare it to a threshold value. When a signal is out of range, a Visual and sound alarm has occurred. I use the VI beep.vi to generate the sound. Everything works fine except the sound alarm. It gives the table 1 d of type mismatch. I tried to fix this by placing it in a box structure. But it still does not work. If someone could help? Please find attached my VI. Best wishes to all visitors to the Forums of Discussion OR.
Ihab El-Sayed
published here: http://forums.ni.com/t5/LabVIEW/Playing-sound-based-on-exceeding-a-threshold-value-1D-array-data/m-p...
-
Get the sum and lastvalue in one request
I have this table
ID
type
Balance
1
one
100
2
b
450
3
b
600
4
one
200
5
b
50
And I need the sum and the last value of the column "balance." How can I me below the result with a single query, without nested query?
sum
last
one
300
200
b
1100
50
Try this:
Select a separate type,
Sum (balance) over (partition by type).
LAST_VALUE (balance) over (partition by RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING id type order)
from my_table;
Concerning
Thomas
-
Authentication using the table and the existing database
Very new to APEX here. In authentication methods and was curious to know if it is possible to link the Apex on an existing Oracle database and the table to get information for user name and password. Trying to use the employe_id and last 4 of their social.
Any ideas or things I can read up to get a general idea?JosephPortello wrote:
fac586, thank you. I didn't even know what I had done.Yet one thing that happens now after I corrected my incorrect syntax.
CREATE OR REPLACE FUNCTION EmployeeIDAuth ( p_username IN VARCHAR2, p_password IN VARCHAR2 ) RETURN BOOLEAN IS form l_count NUMBER; BEGIN SELECT COUNT(*) into l_count from table@db WHERE employee_no=p_username AND bdate=p_password; IF l_count > 0 THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END;
Now returns an error of:
Error on line 15: PLS-00103: encountered the symbol "end-of-file" when expects it one of the following values:
not end up dominant static of final instantiable order pragma
manufacturer membership card
1. CREATE OR REPLACE FUNCTION EmployeeIDAuth)
2 p_username IN VARCHAR2,
3 p_password IN VARCHAR2Any other ideas?
Remove the false token form.
-
I have two tables: employees and their departments. I'm figuring the total employees by the Department and the total employees of the entire society. I know I have to use the SUM function, but I can only calculate total employees by Department and company separately. I need to get this result:
Published by: user13675672 on January 30, 2011 14:29DEPT_NAME DEPT_TOTAL_SALARY COMPANY_TOTAL_SALARY RESEARCH 10875 29025 SALES 9400 29025 ACCOUNTING 8750 29025 This is my code: SELECT department_name, SUM(salary) as total_salary FROM employee, department WHERE employee.department_id = department.department_id GROUP BY department_name; SELECT SUM(salary) FROM employee; Can somebody help please? Thank you in advance.
Published by: user13675672 on January 30, 2011 14:31Hello
Something like:
SELECT dname, dept_tot_sal, SUM (dept_tot_sal) OVER () comp_tot_sal FROM (SELECT dname, SUM (sal) dept_tot_sal FROM dept, emp WHERE dept.deptno = emp.deptno GROUP BY dname);
There might be a smarter way, with no re - select.
Concerning
PeterAnalytical functions:
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm -
How to use the capture and the print button
I tried to figure out how to use the capture and the "print" button, or add or what you call. I press it and the whole page of a different color changes, so I try to cut the section I want but I don't know how to send it to the printer. Can someone help me with this. I'm not at savvy with tech stuff, but when I find a recipe or something and it doesn't have an option to print a certain area, I can't understand how to use it?
Thank you
Andi Starbuck
That happens to me is, I click and drag to make a rectangle of yellow selection, and as soon as I raise my finger on the mouse button, the part I've selected is captured as an image, a new tab opens and preview before printing, the image display. I can use the installation of the Page or simply print. But if I close the preview, this temporary image vanishes and I'm back on the page where I started. You see something different?
-
Using the MF and the "open a new tab" + sign opens a new page with a list of site visited recently, which is a very useful tool. It works fine on my two desktop computers, but I can't it to work on the laptop.
I downloaded "New tab Pro" on the laptop (do not even see on desktop computers so don't think about) such that she was like the real deal but nope... do not work. Running the latest version of MF, ideas on how activate it please?
Thank you guys are going to mark as 'resolved' BTW it is no "folder on the desktop named old data from Firefox. Hmmmmmm.
-
After update to 7.0.1 I can't always use the tab key to move to the next field or use the shift and tab key to move to the previous field in forms. He has always worked in previous versions and it is essential for my type of work. Does anyone know of a setting to enable this? If this is not the case, can the developers of Firefox is working on this issue (please). I love Firefox but desperately need this feature to work properly. Thank you!
No - because it works in Mode safe mode, this means an extension is probably to blame. See http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes
-
How can I clear the attraction of the browser to the bottom of the list, I followed the directions using the options and it will be not only clear
Entries in the location bar drop-down list with a yellow star (blue on Mac) at the right end of the bookmarks.
You can delete this an item marked with a bookmark that appear in the list, if you open this url in a tab and click on the yellow star in the address bar.
This will open the "Edit this bookmark" dialog box and you can click on the delete button to delete the bookmark if you want to delete such an entry marked with a bookmark. -
How many phone numbers can be connected simultaneously, use the most and merge buttons
How many numbers phones can be connected at the same time, use the most and fusion of the buttons after you make the first call?
It depends on your operator.
It's been a few years since I've really looked into it, but I think that AT & T supports up to 5 concurrent calls. I know that other major U.S. carriers support less, but I don't remember the exact numbers. I want to say that Verizon and Sprint are in charge 3 and T-Mobile supports 2, but my memory on this subject is blurred.
Contact your operator for more information.
-
My iMac cursor is stuck in the upper left corner of the login screen and I can't move it and now I can't use my iMac. What can I do? My iMac is a 27-inch 2014 release (one thin without retina display) and uses the keyboard and wireless mouse. It runs OSX Mountain Lion (not sure which version) and is a model 27 inches.
have you tried to change the batteries in the mouse?
-
I use iphone 5 s updated to 9.2, but I can't use the network and call someone help me please
What happens when you try to use the network?
-
I finished the installation of Sharepoint 2010 and went through the Setup Wizard. It is said to use the username and password you loged on the server with does not work. What should I do to access the sharepoint URL?
Hello
Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the TechNet Forum. You can follow the link to your question:
http://social.technet.Microsoft.com/forums/en-us/sharepoint2010general/threads -
my window is too far to the right and ive tried to get to the original size and it will until a certain point to the left. This leaves me unable to use the max and min and exit tabs
Hello
1. What is the brand and model of the computer?
2. is it a laptop or a desktop computer?
3. the problem occurs after leaving the game or program?
4 did you a recent software or changes to the material on the computer?
Method 1:
If this happens when you leave a game, I suggest you to follow the steps mentioned in the link and check.
Open the troubleshooter of display quality
http://Windows.Microsoft.com/en-us/Windows7/open-the-display-quality-Troubleshooter
Method 2:
I also suggest you go through the steps mentioned in the link and the Coachman.
Change your screen resolution
http://Windows.Microsoft.com/en-us/Windows7/change-your-screen-resolution
Method 3:
Step 1:
I also suggest you to check if the problem persists in safe mode.
Start your computer in safe mode
http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode
Step 2:
You can also check if the problem persists in a clean boot state.
Clean boot:
This could happen if one of the substantive programmes is in conflict with the proper functioning of your computer. To help resolve the error and other messages, you can start Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.
How to troubleshoot a problem by performing a clean boot in Windows Vista or Windows 7 http://support.microsoft.com/kb/929135
Note: when you are finished troubleshooting, follow step 7 article to start the computer to a normal startup.
Hope this helps and keep us posted.
-
Arrow keys on the keyboard. Try to use the keyboard and mouse.
New Gateway laptop with windows 7. I play a lot of games online and I can't find anywhere how to change this, or if it's the phone or the operating system. When I try to play a game on IE with the arrows that they automatically stick causing the game almost impossible to play, also when you try to use the keyboard and the touchpad the touchpad locks when the keyboard is in use. Help, please.
It is a known problem if all goes well with Flash and Internet Explorer.
Source: http://social.answers.microsoft.com/Forums/en-US/vistagaming/thread/d006871e-4701-4e80-9062-197f28251ac5/
Maybe you are looking for
-
Tecra 9100 does not supply power to the top
Hello I got Tecra 9100 laptop computer and you have a POWER PROBLEM.Basically, it got stuck at the start of the OS and I was unable to click or move the mouse to do something. So I held the power button to turn it off. I do not turn on again entered
-
I already bought RE4 in my xbox 360, I have to buy again for the xbox one? Than average I loose my progress which I don't mind at all, but at least should be the new HD version
-
Error 737 D. I can't find a solution
An update for Microsoft SQL server 2005 continually refuses to install. The solutions I've tried don't work
-
Conflict of ENE CIR Receiver in Windows 7
I have a dv5-1138nr orginially came with Vista 64 bit. I recently installed Windows 7 prof 64 bit. I'm having a problem with the HP Media remote that I have. It does not work, none of the buttons on the remote work. I installed Win 7 64, ENE CIR rece
-
HP officejet J4680 does not print to web
I have an officejet J4680 which does not print web pages, it prints everything else as of the word, but it will not print from the internet. I have the windows operating system 7. If anyone knows why it's hapenning let me know, thanks