Query Pages Printed By Percentage Of Total?
I'm very new to MySQL and have a query I'm trying to achieve, if anyone can point me in the right direction, I would greatly appreciate it. I have a table created to store print job logs from a print server:
Table = printLogs
logNum mediumint(8)
logDateTime datetime
docNum tinyint(3)
docName varchar(200)
owner varchar(25)
printerName varchar(25)
printerPort varchar(50)
sizeInBytes varchar(50)
pagesPrinted smallint(10)
What I'm trying to do is find a query that, based on a 'printerName', will display 'owner' and percentage derived from the total number of pages printed to that 'printerName' for a given date range.
Something like this:
+--------+--------------------------+
| owner | Percentage of total jobs |
+--------+--------------------------+
| Mary | 50% |
| John | 30% |
| Kim | 10% |
| Sue | 10% |
+--------+--------------------------+
Each row of the table is a different print job and can be one of about 20 different owners who have printed any number of pages to any of 10 printers. The main reason for the query is to be to determine which group/owner uses each printer the most.
View Complete Forum Thread with Replies
Related Forum Messages:
Query Results By Pages
I would like to display query results in pages of say 20 results each. e.g. a table with two columns, serial# and descrition, with a few thousand entries. What would be the SQL query to find a specific serial number, and display all 20 results within the "page" that row happens to be in? e.g say serial#=3211 is in row 64, display rows 60->79.
View Replies !
Percentage Query
I would like to build a query that returns a scoring percentage on several fields in one table. The result if every condition is true, should be 100% and for instance if one condition is not true 95 percent and so on. I would like to have returned the id's and the scoring percentage. Is there a clever way to do a query like that besides going through the database several times like first selecting on a 70% score then on a 75% then.... and finaly he 100% score?
View Replies !
Query Result Percentage
how I might be able to get each record's query match percentage? What I mean is, say your query contains multiple criteria, of which, a variable number of fields per row will match. You see this often with dating services, e.g. name, height, weight, hobby, etc. Not all fields will match so a percentage is provided, then you can sort by percentage. Is there a mySql function that can do this or must this be done the tedious way - like using PHP to test each value against each field's data per row, then updating, then sort
View Replies !
A Query To Select A Column When A Percentage Of Values Non Zero?
I wounder whether some of the experts out there might be able to help me with a problem I'm having. I do not know whether this is possible or not... I have a large table of stock price data which is straight-forward enought. I can select prices based on a ticker and date ranges. However, what I'd like to do is to select prices only when, say 75% of them are non-zero (with the goal of eliminating new/suspended/delisted stocks). Of course I could just select where price > 0, but then I might get only a few rows where this is the case. What I would like to do is always get the full date range of prices, but only if >75% are there.
View Replies !
Sub Total Query
I am pretty new to this stuff. I am trying to total the quantity colum in a table but on for each group. The quantity contains multiple instances of on certain part number and I group the results by part number. I need to get a total quantity from this. Here is what I have....
View Replies !
Subtotal Total Same Query
trying to run this query php program, is it possible or practical? query works if i take out line "sum(subtotal) as calcTotal" otherwise it errors out. any other way i can calculate total of all the items? $sql = $connection->query("select sum((itemProdPrice * itemProdSize)*itemProdQty ) as subtotal, sum(subtotal) as calcTotal from items where itemOrdId = {$_SESSION['order_no']} and itemCustId = '$custId' ");
View Replies !
Total Like Records Query
Ime probably missing the boat here so please be patient. I am trying to create a query to display the total number of records with the same parent name. Eg Total records for author Eddings = 10 So in effect i want to count all the entries and display only the numeric figure of books for that author. I think its supposed to look something like: Select sum(Eddings) $total From books
View Replies !
Calcuate Row Total And Its Cummulative Total
1. I hava a table structure like. EID Day1 Day2 Day3 RowTotal CumTotal And Results will be EID Day1 Day2 Day3 RowTotal CumTotal 1 1 0 0 1 1 1 0 1 0 1 2 1 0 0 1 1 3 How to calculate RowTotal and CumTotal in INSERT or UPDATE or SELECT Statement 2. I hava a table structure like. EID Day1 Day2 Day3 1 1 0 0 1 0 1 0 1 0 0 1 But I want after SELECT Statements Executes in the Following EID Day1 Day2 Day3 RowTotal CumTotal 1 1 0 0 1 1 1 0 1 0 1 2 1 0 0 1 1 3 How to calculate RowTotal and CumTotal in SELECT Statement
View Replies !
How To Get The Total Number Of Rows With A Query "limit" ?
I would like to paginate the results of a query on several pages. So I use a query with a limit X offset Y to display X results on a page. But for the first page, I need to run the same query with a count(*) to know how many pages I will get (number total of rows/ X). The problem is my query is very slow (maybe 5s) because there is much worch to do, and on the first page, I need to run this query twice (not exactly, but ...) so the page is very very slow to load. My question is : is there a function to get the total number of rows even on a query with "limit" ? Or what could I do else ?
View Replies !
Trying To Get Total Count Plus Count From WHERE Clause In One Query
I am fairly familiar with mysql, have been using it with php for about a year now for my development work. One query I am stuck on is the following. I am doing reporting, and need to find the count from a WHERE clause compared to the total count for that group. For the sake of an example, let's say I have a prize table that contains a complete list of prizes. There is a column to list if the prize has been won or not (prizeUsed - Y or N) and another that has the prize name (prizeName - string). I want the final result to list something like: Total Prizes ____________________ 100 of 850 ......
View Replies !
Usergroups On Pages
I am trying to make some type of simple CMS, and I have a table for pages, and I want it so that when the user is making the page, they have an option for what usergroups they want to be able to see it. The admin will be making the usergroups themself, so I don't think I would be able to use SET. ANy idea on what I would put in my "usergroup" table or my "page" table? Or any other method of doing this.
View Replies !
Pages With Mysql
i'm looking to do pages with stuff out of mysql. lets just say i have a long list of names in the database and i want to display 10 at a time and have "<<Prev 1 | 2 | 3 next>>" display for each page. like this: name1 name2 name 3 name4 name5 name6 name7 name8 name9 name10 <<Prev 1 | 2 | 3 next>> i've tried doing something like this before but it's never worked right.
View Replies !
Popular Pages
Is it possible to use data from the url, record it into MySQL or text data file so as to display the popular pages from a site. Any PHP+MySQL ideas or links are needed? ----------------------------- I had the idea started with no luck... the url is basic structure like: domain.com/tmplate.php/1038/BMW list($first, $last) = explode('/', substr($PATH_INFO,1)); $entry_line = "$first/$last "; $fp = fopen("/public/count.txt", "a"); fputs($fp, $entry_line); fclose($fp); the explode grabs the 1038/BMW from the url and records into a text file.
View Replies !
Exit Pages
I have a database that contains all the pages requested on a certain site and the ip of the requester and a timestamp. Is it possible in an sql statement to get a count of the exit pages. ie. count the number of times each page was the last page requested by that IP within a given time frame?
View Replies !
Search/Results Pages
My Search page works, My results page doesn't want to display the results properly and I think the problem lies with my select statements. I am searching for a match between a selected Event Name in the db to a user Event Selected. All one table called Events. The result only displays one row of information when there are 2 matches in the db. The Event Name selected on the Search page is a drop down menu of choices with a Submit button and Event Names do have spaces and hyphens in them which the db stores verbatim.
View Replies !
Navigate Pages By First Two Letters Of Name
I am creating a PHP/MySQL application (if you can call it that). The purpose of this part of the project is to display all of the records in the database ordered by first name. Right now I am selecting each record according to the first letter of their name: A, B, C, etc using a URL parameter. The flaw with this method is when there are only a few records for any given letter, and there are empty queries for letters like Z and X, but not all of the time, and as the list expands I wouldn't want to be changing the navigation. I believe a better method would be to create the query so that you navigate through the pages of the total records (ordered alphabetically ASC) by the first two letters of the first and last records on each page. I'm not advanced enough yet to know exactly how to do this and I was hoping I could get some help. I hope I am explaining this well enough. The other information that would help you help me: For each record, there is a "name_first" field which is what I need the first two letters from. There are three tables I am getting this information from: "men", "women" and "children". There are other variables in the query: "online" and "categoy". The query is currently: $query_men = sprintf("SELECT * FROM men WHERE name_first LIKE '%s%%' AND online LIKE '%%Y%%' AND category LIKE '%%Men%%' ORDER BY name_first ASC", $colname_men);
View Replies !
Pages Are Created On The Fly By Rows...
I have a MySQL database and I want to echo one field (Title) into a page so it can act as a link to that row. When someone clicks the title, I want that row's information to come up. For example Example Title Example Title 2 Example Title 3 User clicks Example Title 2, Example Title 2 | Example Author 2 Example Description. To be displayed. I know this requires "index.php?=". I just don't know what its called and I can't seem to find any tutorials about it. How is it done?:(
View Replies !
Connection :: Pages Slow
we have end site layout (really fast and made with css+xhtml) so we have insert the mysql connection The page load seems very very slow at middle of page. Page is load within middle, after there are pause of 1/2 second and after load continue .. we don't have meet this problem so, we have comment all last row code.. the row that make problem is mysql connection: $conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione'); mysql_select_db($_CONFIG['dbname']); Have you any idea?
View Replies !
Displaying Certain Dates For Certain Pages?
I am wanting to display certain dates on certain pages. For example: newsletters.php January 2007 Monday 15th January 2007 // link to another page to display the newsletter Tuesday 16th January 2007 // link to another page to display the newsletter February 2007 Saturday 10th February 2007 // link to another page to display the newsletter Sunday 11th February 2007 // link to another page to display the newsletter
View Replies !
Results In Multiple Pages, Takes Too Much Time
I have a table of a million records and wrote a CGI-PERL script to display the results based on the user input. The results might be anywhere from 100 to 1000 per query and presently I am displaying them as 25 results per page. Problem: Each query is taking about 20-30 seconds. My solution: I have tried to optimize the table and also index the table. I have actually converted a MS access database to SQL database, so it wasn't previously indexed. Both optimization and indexing doesn't give any good results. I always get a timeout. ie. it takes longer after indexing and optimizing. 1. I was wondering if someone has a creative solution for this. ie. reduce the time from 20-30 seconds to atleast 10 seconds. 2. I have links of pages of results beneath the first page result. When each of these links are clicked it takes 20-30 seconds again. Is there a way I can reduce the time taken for the subsequent pages are reduced? I cannot use the LIMIT option in mysql, since I have a where clause which has to search through the whole table. I tried using views and using limits, but it takes as much time.
View Replies !
PROBLEM WITH JSP PAGES, BLOB AND MYSQL DATABASE
I have a html form and I am using the <input type="file"> tag in order to store a blob image file into my MySQL datase. The problem is that I don't know how to get the file and store it. I write Java Scriptles in the JSP pages (this means pure java).
View Replies !
Creating A FTP Server/pages For File Transfer
I've never worked with MySQL before. I need to create a FTP logon page for clients, I'm not sure that MySQL is even the best solution f ro what I want to achieve, but I would appreciate it if someone could give me some advice. An example of what I want to do is at: http://www.rtfacts.co.uk/page2.htm From here click on "Contact us" on the next screen you will see "Click here to go to our FTP site". This is what I want to achieve. Can I achieve this using MySQL or is there an easier way? The hosting service I use provides MySQL services, so I can set up a database if I need to.
View Replies !
How Do I Make It Dynamic I Dont Want 20 000 Pages Of Data?
I havent really got a clue what im doing so i need some help I am tryig to create a site with news on it the problem im having is that on my index.php isbring up the headlines with a section of content $leader fine but how do i create a link from the $headline to the same page (dynamic) but only showing the headline and full content of the headline clicked on. I cant get my pages to be dynamic which is the whole idea of using mysql and php so please teach me or send me to some decent tutorials the manual on php.net is to technical it doesnt explain anything and the other tutorials out there are to simple they dont get into the complex stuff. here is the code <? include("inf.php"); mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ($tablename)"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $datetime=mysql_result($result,$i,"datetime"); $subject=mysql_result($result,$i,"subject"); $headline=mysql_result($result,$i,"headline"); $leader=mysql_result($result,$i,"leader"); $content=mysql_result($result,$i,"content"); ?> <!-- Begin #main --> <div id="main"> <div id="main2"> <div id="main3"> <h2 class="date-header"> <? include("site/includes/time.php"); ?> </h2> <div class="post"> <h3 class="post-title"> <!-- On the main index.php page I want 5 headlines and then I want the headline to link to this same (dynamic) page but with the variable $content also showing and the other four headlines no longer showing --> <a href="Article alone page" title="permanent link"><? echo "$headline"; ?> </a> - posted on <? echo "$datetime"; ?></h3> <div class="post-body"> <p> <b><? echo "$leader"; ?></b> </p> </div> </div> <div class="post"> <div> <br /> </div> </div> </div></div></div> <!-- End #main --> <? ++$i; } ?>
View Replies !
Display All Results Vs Spliting Up Over Number Of Pages
I have built a site for a local auction house. Each auction has around 2000 lots, which are held in the table auction_items with references to another 3 tables. I am trying to work out the best way of displaying all of the items for a given auction, whilst optimising performance. Each site visitor typically wants to see all of the items in the list and wants the option to "show all" items in a single view. From past hits we estimate approximately 700 hits a day, most of which will want to view the list of items. Are there performance benefits to be gained from displaying the results 20 to a page and having the users scroll through? Rather than loading the full list once per user? From a usability point of view they would be better off with one list that they can see "at a glance" and print.
View Replies !
Percentage
I have a table of score which are 1's and 0's. How would I go about writing a query to get the percentage of 1's against the toal number of records?
View Replies !
Get Top X Percentage
I am trying to do a report that tells us our top selling products in a table where I already have the data compiled: product_code, product_name, total_dollars I would like to be able to query and say give me the top 50% of our products. Finding the top 50% in a dollar value is easy. Applying it to the table to return the best selling products until the sum of their total_dollars is equal to 50%.I'm usually pretty bad with mysql math, so I was hoping someone could help. I'm sure this is a fairly common mysql procedure, but I've never done it before...
View Replies !
Percentage On The Fly
My table now looks like this : vote_id*, voter_id, vote_date, voter_ip, votee_id, title_id. I have the first part of the query working ok SELECT votee_id, title_id, COUNT( vote_id ) FROM jos_comprofiler_plug_fun2 WHERE votee_id =79 GROUP BY title_id; Nice and simple it gives me the number of votes each title has according to a specific votee: votee_id, title_id, COUNT( vote_id ) 79, 1, 1 79, 2, 1 79 , 3, 4 79 , 4, 2 79 , 5, 1 79 , 6, 1 But how do I change this query to give me the percentage of votes each title has according to a specific votee?
View Replies !
Building Dynamic Pages For Editing Database Records
I need to develop a way for my client to edit information in a MySQL database. Basically, something very similar to how PHP MyAdmin works only slighly less complicated. There does not need to be the ability to edit the structure of the database or tables or anything like that, simply the information and entries. I have searched google and yahoo with the following phrases, but have found that most of the results are topics on how to use database editors or where to buy third party software. ------ database administration pages Building MySQL Admin pages building web admin page build a web based database administration console build PHP my admin pages from scratch My SQL Admin pages create web based database administration Creating administration pages Creating web admin page from Access in php ------ I've also searched CodingForums.com for threads from others that may have been trying to do the same thing. I didn't really find anything relevent. Perhaps someone could lead me in the right direction or tell me if I'm not searching correctly. What I'm trying to do has to have been done before, I'm just not having any luck on finding the right information. I figure that I'm going to end up building this from scratch with PHP, but I thought I'd ask to see where to start or if there are examples out there that I may be able to model after.
View Replies !
Calculating A Percentage
I'm working on an adp file and I'm trying to do is calculate what percentage one figure is of another figure in a view. In access I would simply do it like this: [FirstField]/[SecondField]*100 But this doesn't seem to work. My exact code is as follows: SELECT Product, Quarter, TotalPlanProductSpend, TotalPlanSpend, TotalPlanProductSpend / TotalPlanSpend * 100 AS PercentOfTotal FROM dbo.Qry_RptPlanPRoductSetup
View Replies !
Percentage Of Votes
i made a script for my buddy that his clients can vote and wright comments on his service. in my database i have 3 fields vote comments web so vote is the votes rated and web is the rates rated for the web site. now i want to extract the total percentage of votes? i have a start..from searching on Google mysql percentage SELECT (SUM( votes ) / COUNT( votes )) *100 percentage FROM `votes`
View Replies !
Returning A Percentage
is it possable to return ONLY 20% percent of the overall possable returns in a query? e.g. i have 100 possable returns and i only want 20% of them. So i'd receive 20 returns. What i'm trying to do exactly is return the latest 30 entries and then the next 20% of the possable entries. i'm working with a database that has thousands of possable returns but i don't want all of them.
View Replies !
How Do I Increase A Cost By A Percentage?
currently training on SQL - doing alright so far until this sub-question... Migrate all data from the JOB_COST table into the TOTAL_COST table. For those records that match the COST_ID, update the UPPER_LEVEL and increase the cost by 15%, otherwise insert the records.
View Replies !
Calculate Series Percentage
Is there a way to calculate the percentage of a series of values in MySQL? I need to have the total of sum in order to calculate the percentage in each row. How can I do this in the following query? SELECT product.productId, product.name, COUNT(product.productId) AS count, SUM(invoice.value) AS sum FROM product, invoice WHERE product.productId=invoice.productId GROUP BY product.productId
View Replies !
Percentage Correct Calculation
I"m not sure this is the right way to do things - but it's the web site database I do have now that I"m using. It's a pretty simple 'pick the winners' database Table - Picks userID gameID pickedteamID gameresults gameID winnerID What I need is a query that will return the total number of picks for a user as one column and a count of the correct picks...(ideally i want a percentage) - say i've picked 16 games and 8 correct...i would want the result to be jemagee 8 16 .5 (percentage correct) THe problem is of course I want to select ALL users and order descending by the percentage count so I can list a standings. Is this doable in mysql alone? Did it make sense.
View Replies !
Getting Totals(or Percentage) Of Each Field
Say i have a select statement which selects 5 fields and displays the results as follows: field1 | field2 | field3 | field4 | field5 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 how can i add one more row to the output, which would calculate the total of each field and display at the bottom of the table?? for above example, the output should look like: field1 | field2 | field3 | field4 | field5 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 10 | 20 | 60 | 80 | 40 Total 50 | 100 | 300 | 400 | 200
View Replies !
Finding Percentage Of Column
I attempting to add a column of data that calculates the percentage a data element comprises. The following is an example of the data I have so far: Diagnosis | COUNT(diagnosis) ----------+----------------- cough | 10 acne | 20 diabetes | 20 This is what I'm trying to produce: Diagnosis | COUNT(diagnosis) | Percentage ----------+------------------+----------- cough | 10 | 20% acne | 20 | 40% diabetes | 20 | 40% This is what I've attempted to do but get a "invalid use of group function" error when I try to embed the COUNT function inside the SUM function. SELECT diagnosis, COUNT(diagnosis), (COUNT(diagnosis) / SUM(COUNT(diagnosis))) AS "percent" FROM diagnosis_table.all_diagnosis GROUP BY diagnosis; The value I'm attempting to calculate in "SUM(COUNT(diagnosis))" is the total summation of all the cases in column "COUNT(diagnosis)." Once I have that value, I divide it into the value "COUNT(diagnosis)" to determine the percentage a particular diagnosis comprises out of the total in that table.
View Replies !
Percentage Of 2 Year Data
I am having the toughest time trying to figure out how to get a percentage from my tables. 1. I Have 12 tables from 2005 named January2005, February2005 etc. up to December2005. I also have 12 tables for 2006 name January2006 etc. 2.In these tables is a column named Result and the value is either Won or Lost. I am counting how many times is says Won or Lost and getting a Total for each Month. "Select Count(Result) From January2005 Where Result = 'Won'; 3.I am getting a percentage for 2005 and 2006 just fine. SELECT Round(((WonTotal)/Val((WonTotal)+(LoseTotal))*100)) FROM WinTotal, LoseTotal; This is the problem: I need to take 2005 and 2006 and combine them to get a total percentage of Won.
View Replies !
MySQL Column Value As Percentage
On my site, I log all visitors to a MySQL database. One value in the table is their browser, which is either IE6, IE7, Opera, Konqueror, Safari, Firefox, or Other if it isn't any of those. I want to create a list which shows what percentage of users use each browser. For example: Firefox: 31% IE7: 29% IE6: 18% Safari: 8% Opera: 5% Other: 5% Konqueror: 4% Those are completely made-up figures, by the way.
View Replies !
Wildcard Return Percentage Match
I am trying to write an query which will return the percentage match of a wildcard search in mysql.I am using the LIKE command. eg ( Word in table= Barack Obama Word passed to query= Barack percentage match:50%(I know this percentage isn't correct) ) Is this possible in SQL?
View Replies !
Working Out The Occurrence Percentage In A Column
I wondered if anyone knew if it is possible to work out a percentage of the occurrence of a text value in a column in a MySQL database. I have a compliance column with simple yes/no answers and need a percentage for the amount of times yes is entered.
View Replies !
|