Hi,
I have 4 columns workID, Description, work & Rework . On the basis these four columns i have to generate four more columns as total Work,%work, %Rework, %Total Work. we have some dummy data. So Now my question is how to write stored pocedure to select in case of the above scenaraio.
Thnks.
Hey.
If I am understanding you correctly, you don't really need a procedure.
You could simply do something like: - SELECT
-
`id`, `description`, `work`, `rework`,
-
(`work` + `rework`) AS `total_work`,
-
(`work` / (`work` + `rework`) * 100) AS `% work`,
-
(`rework` / (`work` + `rework`) * 100) AS `% rework`,
-
((`work` + `rework`) / (SELECT SUM(`work` + `rework`) FROM `work_table`) * 100) AS `% total work`
-
FROM `work_table`;
1 1495 Atli 5,058
Expert 4TB
Hey.
If I am understanding you correctly, you don't really need a procedure.
You could simply do something like: - SELECT
-
`id`, `description`, `work`, `rework`,
-
(`work` + `rework`) AS `total_work`,
-
(`work` / (`work` + `rework`) * 100) AS `% work`,
-
(`rework` / (`work` + `rework`) * 100) AS `% rework`,
-
((`work` + `rework`) / (SELECT SUM(`work` + `rework`) FROM `work_table`) * 100) AS `% total work`
-
FROM `work_table`;
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Trosen |
last post by:
Hi Everyone,
I hope someone can help, I'm pretty new to pro*c programming.
I have the following application setup:
a pro*c program calls a stored procedure and recieves a cursor back:
the...
|
by: Rob Wire |
last post by:
For the code below, how could I add an item in the drop
down lists for both company and location to be an "All"
selection that would send to the stored proc.
spRptAttachments a value of "%" so...
|
by: mandible |
last post by:
Hello I was wondering if I"m doing something wrong with using db2advis
I have 2 stored procedures are are massive, I created an input file to
call both of these stored procedures and I dont' seem...
|
by: ccorbett |
last post by:
Hi,
I am pretty new to microsoft programming environment. I want to create
forms in visual basic 2005 studio that read data from stored procedures
and load into the forms for editing and new...
|
by: Sirisha |
last post by:
Hi,
I am inserting values into databse using sqlserver stored
procedures. i wrote stored preocedure,but in codebehind file(.vb file)
i dont know how to pass the parameters, i got error message...
|
by: Sirisha |
last post by:
Hi,
I am inserting values into databse using sqlserver stored
procedures. i wrote stored preocedure,but in codebehind file(.vb
file)
i dont know how to pass the parameters, i got error message...
|
by: brwalias |
last post by:
Hi,
using .net 2
sql server 2005
Here is my situation:
I'm passing a variable in the url from a selection on Page A and need
to display the results on the Results page be based on that...
|
by: Ryan |
last post by:
PLEASE HELP!!
I am trying to do what I think should be the simplest thing. In
Visual Studio 2005, I set up a datagrid and then went ot configure a
datasource for it. I made my connection to...
|
by: COHENMARVIN |
last post by:
I found that I'm making an error in my 'case' statements, and now I
want to go through a database full of many stored procedures to find
that error in some of them and to fix it. Is there any way...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |