473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

calc % from 1 col 1 table

4
Hello,

I am attempting to figure out market share % for contracted widgets (ie CVRid for contracted = 50 and competitive = 55). All data is in a single table. It needs to grouped by TC where the BKid is the same.

table 1
col1 - TC
col2 - TCid
col3 - bKid
col4 - CVRid
col5 - Units
col6 - Prod_num

within any TC is any number of prod_num's that can have a CVRid of either 50 or 55, so I am trying to get..." sum(50/50+55)*100".

Have tried three different ways and am getting various errors or empty sets. ugh

Rick
Aug 3 '11 #1
5 1715
ck9663
2,878 Expert 2GB
Could you post some sample data and how you want the result to look like?

Also, could you post whatever you have so far?


~~ CK
Aug 3 '11 #2
Reden
4
CK,

Here is one of the versions. Please notice that a prod_num can be in several TC's.

Thx,
Rick

(select t1.TC,t1.TCid,sum(t1.units))
from test_db as t1
join test_db t2 on
t1.TCid = t2.TCid
where t1.CVRid = t2.CVRid and t1.BKid = t2.BKid and t1.TCid = t2.TCid
group by t1.TC

/
(select sum(t1.units)
from test_db as t1
join test_db t2 on
t1.TCid = t2.TCid
where t1.CVRid = t2.CVRid and t1.BKid = t2.BKid and t1.TCid = t2.TCid)


TC Tcid Bkid CVRid Units prod_num
TC-A 2 1 50 25 423
TC-A 2 1 50 20 335
TC-A 2 1 50 10 112
TC-A 2 1 55 5 245
TC-A 2 1 55 20 276
TC-A 2 1 55 10 275
TC-B 3 1 55 10 275
TC-B 3 1 55 20 276
TC-B 3 1 50 25 300
TC-B 3 1 50 20 325
Aug 3 '11 #3
Reden
4
sorry forgot to add output

TC-a XX.XX%
TC-B XX.XX%
etc.

Thank you
Aug 3 '11 #4
Reden
4
I figured it out, I was making it more difficult than it needed. All Set.

R
Aug 5 '11 #5
ck9663
2,878 Expert 2GB
Sorry about the late reply...Can you post what you did so we can share it with everyone?

Happy Coding!!!


~~ CK
Aug 8 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Astra | last post by:
Hi All Wonder if you can help me with the following calc, which I want to create to check whether or not a user has entered a valid credit card expiry date: 1) I have retrieve a value from 2 x...
4
by: Kim14 | last post by:
I have a table that works fine in IE, but doesn't work in Netscape or Firefox. It should automatically come up with numbers in some of the fields and depending what is entered, it should calculate...
1
by: gbb0330 | last post by:
hi all i am using access 2003 my form is called i have a textbox, name - with control source: =----- visible is set to No
4
by: qtip | last post by:
I have a simple table the has First Name , Last Name, SSN, Date&Time. I have a report that will show all this information but I would like to put in at calculation to tell the difference between 2...
4
by: coleenholley | last post by:
Ok, after all the research on datagrids, I've found that they won't really work for what I'm trying to do...I have a table that I need to have three columns as static data (but each row has a...
2
by: Jason | last post by:
I am trying to create a simple database, but it's proving too complex for me!!! I have only just started a new database and am trying to have two fields in a table: the first holding the first...
34
by: MLH | last post by:
http://www.opm.gov/Fedhol/ http://www.opm.gov/Fedhol/2008.asp Federal law (5 U.S.C. 6103) establishes the following public holidays for Federal employees. Please note that most Federal employees...
2
by: kevinjbowman | last post by:
I am by no means a SQl Jedi as will be apparent by my question, but I can usually figure out a select statement on my own. I have one today though that really has me stumped. I am working in...
21
by: mm | last post by:
(Yes, I konw whats an object is...) BTW. I did a translation of a pi callculation programm in C to Python. (Do it by your own... ;-) -------- Calc PI for 800 digs(?). (german: Stellen) ------...
7
by: sparks | last post by:
I am working on a database that has a lot of calculated values on the forms. These were never put into the tables. But were tied to unbound fields on the forms. Now 8000 records later they want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.