Search Results

Search found 8083 results on 324 pages for 'total newbie'.

Page 78/324 | < Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >

  • simple rank formula

    - by Graham
    I'm looking for a mathmatical ranking formula. Sample is 2008 2009 2010 A 5 6 4 B 6 7 5 C 7 8 2 I want to add a rank column for each period code field rank 2008 2009 2010 2008 2009 2010 B 6 7 5 2 1 1 A 5 6 4 3 2 2 C 7 2 2 1 3 3 please do not reply with methods that loop thru the rows and columns, incrementing the rank value as it goes, that's easy. I'm looking for a formula much like finding the percent total (item / total). I know i've seen this before but an havning a tough time locating it. Thanks in advance!

    Read the article

  • PHP 2d array question

    - by Neral
    Hello, So i have a 2 dimensional array that is used over several pages (session) $_SESSION ["Table"][$_SESSION ["count"]] [0] = $filename; $_SESSION ["Table"][$_SESSION ["count"]] [1] = $size; $_SESSION ["Table"][$_SESSION ["count"]] [2] = $floor; $_SESSION ["Table"][$_SESSION ["count"]] [3] = $phone; $_SESSION ["Table"][$_SESSION ["count"]] [4] = $network; $_SESSION ["Table"][$_SESSION ["count"]] [5] = $totalprice; This is used with a form so i can give in multiple input wich gets stored. But my question is how exactly can i calculate the AVERAGE of $total price of all given in results? Meaning for example i have 5 rows so this would mean 5 total prices. How exactly can i acces this value and count everything up / 5? This will happen in a other page so i would like to use sessions for this. /5 simply by count($_Session["table"]) , but really not sure about the other values. Kind Regards.

    Read the article

  • Counting number of searches

    - by shinjuo
    I am trying to figure out how to get the total number of tests each search makes in this algorithm. I am not sure how I can pass that information back from this algorithm though. I need to count how many times while runs and then pass that number back into an array to be added together and determine the average number of test. main.c #include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include "percentage.h" #include "sequentialSearch.h" #define searchAmount 100 int main(int argc, char *argv[]) { int numbers[100]; int searches[searchAmount]; int i; int where; int searchSuccess; int searchUnsuccess; int percent; srand(time(NULL)); for (i = 0; i < 100; i++){ numbers[i] = rand() % 200; } for (i = 0; i < searchAmount; i++){ searches[i] = rand() % 200; } searchUnsuccess = 0; searchSuccess = 0; for(i = 0; i < searchAmount; i++){ if(seqSearch(numbers, 100, searches[i], &where)){ searchSuccess++; }else{ searchUnsuccess++; } } percent = percentRate(searchSuccess, searchAmount); printf("Total number of searches: %d\n", searchAmount); printf("Total successful searches: %d\n", searchSuccess); printf("Success Rate: %d%%\n", percent); system("PAUSE"); return 0; } sequentialSearch.h bool seqSearch (int list[], int last, int target, int* locn){ int looker; looker = 0; while(looker < last && target != list[looker]){ looker++; } *locn = looker; return(target == list[looker]); }

    Read the article

  • Most efficent way to limit rows returns from union query- TSQL

    - by stephen776
    Hey guys...I have a simple stored proc with two queries joined with a union select name as 'result' from product where... union select productNum as 'result' from product where... I want to limit this to the TOP 10 results... if i put TOP 10 in each seperate query I get 20 results total. What is the most efficient way to limit total results to 10? I dont want to do TOP 5 in each because I may end up in a situation where I have something like 7 "names" and 3 "productsNumbers"

    Read the article

  • C++ HW - defining classes - objects that have objects of other class problem in header file (out of

    - by kitfuntastik
    This is my first time with much of this code. With this instancepool.h file below I get errors saying I can't use vector (line 14) or have instance& as a return type (line 20). It seems it can't use the instance objects despite the fact that I have included them. #ifndef _INSTANCEPOOL_H #define _INSTANCEPOOL_H #include "instance.h" #include <iostream> #include <string> #include <vector> #include <stdlib.h> using namespace std; class InstancePool { private: unsigned instances;//total number of instance objects vector<instance> ipp;//the collection of instance objects, held in a vector public: InstancePool();//Default constructor. Creates an InstancePool object that contains no Instance objects InstancePool(const InstancePool& original);//Copy constructor. After copying, changes to original should not affect the copy that was created. ~InstancePool();//Destructor unsigned getNumberOfInstances() const;//Returns the number of Instance objects the the InstancePool contains. const instance& operator[](unsigned index) const; InstancePool& operator=(const InstancePool& right);//Overloading the assignment operator for InstancePool. friend istream& operator>>(istream& in, InstancePool& ip);//Overloading of the >> operator. friend ostream& operator<<(ostream& out, const InstancePool& ip);//Overloading of the << operator. }; #endif Here is the instance.h : #ifndef _INSTANCE_H #define _INSTANCE_H ///////////////////////////////#include "instancepool.h" #include <iostream> #include <string> #include <stdlib.h> using namespace std; class Instance { private: string filenamee; bool categoryy; unsigned featuress; unsigned* featureIDD; unsigned* frequencyy; string* featuree; public: Instance (unsigned features = 0);//default constructor unsigned getNumberOfFeatures() const; //Returns the number of the keywords that the calling Instance object can store. Instance(const Instance& original);//Copy constructor. After copying, changes to the original should not affect the copy that was created. ~Instance() { delete []featureIDD; delete []frequencyy; delete []featuree;}//Destructor. void setCategory(bool category){categoryy = category;}//Sets the category of the message. Spam messages are represented with true and and legit messages with false.//easy bool getCategory() const;//Returns the category of the message. void setFileName(const string& filename){filenamee = filename;}//Stores the name of the file (i.e. “spam/spamsga1.txt”, like in 1st assignment) in which the message was initially stored.//const string& trick? string getFileName() const;//Returns the name of the file in which the message was initially stored. void setFeature(unsigned i, const string& feature, unsigned featureID,unsigned frequency) {//i for array positions featuree[i] = feature; featureIDD[i] = featureID; frequencyy[i] = frequency; } string getFeature(unsigned i) const;//Returns the keyword which is located in the ith position.//const string unsigned getFeatureID(unsigned i) const;//Returns the code of the keyword which is located in the ith position. unsigned getFrequency(unsigned i) const;//Returns the frequency Instance& operator=(const Instance& right);//Overloading of the assignment operator for Instance. friend ostream& operator<<(ostream& out, const Instance& inst);//Overloading of the << operator for Instance. friend istream& operator>>(istream& in, Instance& inst);//Overloading of the >> operator for Instance. }; #endif Also, if it is helpful here is instance.cpp: // Here we implement the functions of the class apart from the inline ones #include "instance.h" #include <iostream> #include <string> #include <stdlib.h> using namespace std; Instance::Instance(unsigned features) { //Constructor that can be used as the default constructor. featuress = features; if (features == 0) return; featuree = new string[featuress]; // Dynamic memory allocation. featureIDD = new unsigned[featuress]; frequencyy = new unsigned[featuress]; return; } unsigned Instance::getNumberOfFeatures() const {//Returns the number of the keywords that the calling Instance object can store. return featuress;} Instance::Instance(const Instance& original) {//Copy constructor. filenamee = original.filenamee; categoryy = original.categoryy; featuress = original.featuress; featuree = new string[featuress]; for(unsigned i = 0; i < featuress; i++) { featuree[i] = original.featuree[i]; } featureIDD = new unsigned[featuress]; for(unsigned i = 0; i < featuress; i++) { featureIDD[i] = original.featureIDD[i]; } frequencyy = new unsigned[featuress]; for(unsigned i = 0; i < featuress; i++) { frequencyy[i] = original.frequencyy[i];} } bool Instance::getCategory() const { //Returns the category of the message. return categoryy;} string Instance::getFileName() const { //Returns the name of the file in which the message was initially stored. return filenamee;} string Instance::getFeature(unsigned i) const { //Returns the keyword which is located in the ith position.//const string return featuree[i];} unsigned Instance::getFeatureID(unsigned i) const { //Returns the code of the keyword which is located in the ith position. return featureIDD[i];} unsigned Instance::getFrequency(unsigned i) const { //Returns the frequency return frequencyy[i];} Instance& Instance::operator=(const Instance& right) { //Overloading of the assignment operator for Instance. if(this == &right) return *this; delete []featureIDD; delete []frequencyy; delete []featuree; filenamee = right.filenamee; categoryy = right.categoryy; featuress = right.featuress; featureIDD = new unsigned[featuress]; frequencyy = new unsigned[featuress]; featuree = new string[featuress]; for(unsigned i = 0; i < featuress; i++) { featureIDD[i] = right.featureIDD[i]; } for(unsigned i = 0; i < featuress; i++) { frequencyy[i] = right.frequencyy[i]; } for(unsigned i = 0; i < featuress; i++) { featuree[i] = right.featuree[i]; } return *this; } ostream& operator<<(ostream& out, const Instance& inst) {//Overloading of the << operator for Instance. out << endl << "<message file=" << '"' << inst.filenamee << '"' << " category="; if (inst.categoryy == 0) out << '"' << "legit" << '"'; else out << '"' << "spam" << '"'; out << " features=" << '"' << inst.featuress << '"' << ">" <<endl; for (int i = 0; i < inst.featuress; i++) { out << "<feature id=" << '"' << inst.featureIDD[i] << '"' << " freq=" << '"' << inst.frequencyy[i] << '"' << "> " << inst.featuree[i] << " </feature>"<< endl; } out << "</message>" << endl; return out; } istream& operator>>(istream& in, Instance& inst) { //Overloading of the >> operator for Instance. string word; string numbers = ""; string filenamee2 = ""; bool categoryy2 = 0; unsigned featuress2; string featuree2; unsigned featureIDD2; unsigned frequencyy2; unsigned i; unsigned y; while(in >> word) { if (word == "<message") {//if at beginning of message in >> word;//grab filename word for (y=6; word[y]!='"'; y++) {//pull out filename from between quotes filenamee2 += word[y];} in >> word;//grab category word if (word[10] == 's') categoryy2 = 1; in >> word;//grab features word for (y=10; word[y]!='"'; y++) { numbers += word[y];} featuress2 = atoi(numbers.c_str());//convert string of numbers to integer Instance tempp2(featuress2);//make a temporary Instance object to hold values read in tempp2.setFileName(filenamee2);//set temp object to filename read in tempp2.setCategory(categoryy2); for (i=0; i<featuress2; i++) {//loop reading in feature reports for message in >> word >> word >> word;//skip two words numbers = "";//reset numbers string for (int y=4; word[y]!='"'; y++) {//grab feature ID numbers += word[y];} featureIDD2 = atoi(numbers.c_str()); in >> word;// numbers = ""; for (int y=6; word[y]!='"'; y++) {//grab frequency numbers += word[y];} frequencyy2 = atoi(numbers.c_str()); in >> word;//grab actual feature string featuree2 = word; tempp2.setFeature(i, featuree2, featureIDD2, frequencyy2); }//all done reading in and setting features in >> word;//read in last part of message : </message> inst = tempp2;//set inst (reference) to tempp2 (tempp2 will be destroyed at end of function call) return in; } } } and instancepool.cpp: // Here we implement the functions of the class apart from the inline ones #include "instancepool.h" #include "instance.h" #include <iostream> #include <string> #include <vector> #include <stdlib.h> using namespace std; InstancePool::InstancePool()//Default constructor. Creates an InstancePool object that contains no Instance objects { instances = 0; ipp.clear(); } InstancePool::~InstancePool() { ipp.clear();} InstancePool::InstancePool(const InstancePool& original) {//Copy constructor. instances = original.instances; for (int i = 0; i<instances; i++) { ipp.push_back(original.ipp[i]); } } unsigned InstancePool::getNumberOfInstances() const {//Returns the number of Instance objects the the InstancePool contains. return instances;} const Instance& InstancePool::operator[](unsigned index) const {//Overloading of the [] operator for InstancePool. return ipp[index];} InstancePool& InstancePool::operator=(const InstancePool& right) {//Overloading the assignment operator for InstancePool. if(this == &right) return *this; ipp.clear(); instances = right.instances; for(unsigned i = 0; i < instances; i++) { ipp.push_back(right.ipp[i]); } return *this; } istream& operator>>(istream& in, InstancePool& ip) {//Overloading of the >> operator. ip.ipp.clear(); string word; string numbers; int total;//int to hold total number of messages in collection while(in >> word) { if (word == "<messagecollection"){ in >> word;//reads in total number of all messages for (int y=10; word[y]!='"'; y++){ numbers = ""; numbers += word[y]; } total = atoi(numbers.c_str()); for (int x = 0; x<total; x++) {//do loop for each message in collection in >> ip.ipp[x];//use instance friend function and [] operator to fill in values and create Instance objects and read them intot he vector } } } } ostream& operator<<(ostream& out, const InstancePool& ip) {//Overloading of the << operator. out << "<messagecollection messages=" << '"' << '>' << ip.instances << '"'<< endl << endl; for (int z=0; z<ip.instances; z++) { out << ip[z];} out << endl<<"</messagecollection>\n"; } This code is currently not writing to files correctly either at least, I'm sure it has many problems. I hope my posting of so much is not too much, and any help would be very much appreciated. Thanks!

    Read the article

  • Getting count() of class static array

    - by xylar
    Is it possible to get the count of a class defined static array? For example: class Model_Example { const VALUE_1 = 1; const VALUE_2 = 2; const VALUE_3 = 3; public static $value_array = array( self::VALUE_1 => 'boing', self::VALUE_2 => 'boingboing', self::VALUE_3 => 'boingboingboing', ); public function countit() { // count number $total = count(self::$value_array ); echo ': '; die($total); } } At the moment calling the countit() method returns :

    Read the article

  • Stuck on solving the Minimal Spanning Tree problem.

    - by kunjaan
    I have reduced my problem to finding the minimal spanning tree in the graph. But I want to have one more constraint which is that the total degree for each vertex shouldnt exceed a certain constant factor. How do I model my problem? Is MST the wrong path? Do you know any algorithms that will help me? One more problem: My graph has duplicate edge weights so is there a way to count the number of unique MSTs? Are there algorithms that do this? Thank You. Edit: By degree, I mean the total number of edges connecting the vertex. By duplicate edge weight I mean that two edges have the same weight.

    Read the article

  • Make the Enter key act like the submit button

    - by Michael Quiles
    How can I make it where some one presses the enter key on my form it will submit this code ? Ive tried the ligtning bolt events etc... but I can't seem to figure it out. private void xTripSubmitButton_Click(object sender, EventArgs e) { // Calculates the numbers from the input and output boxes/labels Miles = double.Parse(this.xTripDestinationTextBox.Text); Mpg = double.Parse(this.xTripMpgTextBox.Text); Price = double.Parse(this.xTripPricepgTextBox.Text); Output = Miles / Mpg; Coutput = Output * Price; //displays a message and the result for the numbers the user inputs this.xTripOutputLabel.Text = "Total gallons you would use: " + Output.ToString("0") + Environment.NewLine + "Total amount it will cost you: " + Coutput.ToString("C"); }

    Read the article

  • Sum of a PHP Array

    - by user1879415
    The following code displays the ordered products individual weight: $weightsql = 'select op.products_name, op.products_quantity , p.products_weight from ' . TABLE_ORDERS_PRODUCTS . ' op left join ' . TABLE_PRODUCTS . ' p on op.products_id = p.products_id where op.products_id = '.$pro['products_id']; $weightq = tep_db_query( $weightsql ); while ($weight = tep_db_fetch_array( $weightq )){ if($category_parent_id != 0)$list_items[] = $weight['products_weight'].'&nbsp;&nbsp;&nbsp;'; } This shows the wieght for each of the products ordered. What I am stuck on is instead of showing seperate weights, I need to show a total weight. For example, if the product was ordered three times, and it weighs 7kg, the code at the moment is showing: Product 7.00 7.00 7.00 How would I make it show the total weight, 21kg?

    Read the article

  • Jsoup to get data on <b> block

    - by Poh Sun
    I'm new to JSoup on Java and would like to enquire few questions. Given the HTML code of the page I would like to get is this <td width="70%" class="row1"> <b>4</b> <br />( 0 posts per day / 0.00% of total forum posts ) </td> My question here is I want to get the data 4 but the output I get is 4 ( 0 posts per day / 0.00% of total forum posts ) Here is my Java code Iterator <Element> element = totalPost.select("td[width=70%][class=row1]").iterator(); System.out.println(element.next().text()); Sorry if my question is not clear enough.

    Read the article

  • Inventory count in CakePHP

    - by metrobalderas
    We are developing an inventory tracking system. Basically we've got an order table in which orders are placed. When an order is payed, the status changes from 0 to 1. This table has multiple children in another table order_items. This is the main structure. CREATE TABLE order( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, user_id INT UNSIGNED, status INT(1), total INT UNSIGNED ); CREATE TABLE order_items( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, order_id INT UNSIGNED, article_id INT UNSIGNED, size enum('s', 'm', 'l', 'xl'), quantity INT UNSIGNED ); Now, we've got a stocks table with similar architecture for the acquisitions. This is the structure. CREATE TABLE stock( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, article_id INT UNSIGNED ); CREATE TABLE stock_items( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, stock_id INT UNSIGNED, size enum('s', 'm', 'l', 'xl'), quantity INT(2) ); The main difference is that stocks has no status field. What we are looking for is a way to sum each article size from stock_items, then sum each article size from order_items where Order.status = 1 and substract both these items to find our current inventory. This is the table we want to get from a single query: Size | Stocks | Sales | Available s | 10 | 3 | 7 m | 15 | 13 | 2 l | 7 | 4 | 3 Initially we thought abouth using complex find conditions, but perhaps that's the wrong approach. Also, since it's not a direct join, it turns out to be quite hard. This is the code we have to retrieve the stock's total for each item. function stocks_total($id){ $find = $this->StockItem->find('all', array( 'conditions' => array( 'StockItem.stock_id' => $this->find('list', array('conditions' => array('Stock.article_id' => $id))) ), 'fields' => array_merge( array( 'SUM(StockItem.cantidad) as total' ), array_keys($this->StockItem->_schema) ), 'group' => 'StockItem.size', 'order' => 'FIELD(StockItem.size, \'s\', \'m\' ,\'l\' ,\'xl\') ASC' )); return $find; } Thanks.

    Read the article

  • Does thread pool size keep growing for scheduledthreadpoolexecutor?

    - by Sourajit Basak
    Imagine a situation where tasks are being added to scheduledthreadpoolexecutor. Each of these tasks will keep on running at different periodic intervals. Although all such tasks will not be running at the same time because each is set at different intervals, there may be a situation where a high number of threads are competing for execution. Is there any restriction on total number of threads ? It seems there is a restriction on the total number of idle threads. And does this concept of idle thread imply that long running tasks (thread) may be destroyed and recreated when needed ?

    Read the article

  • Mysql Query - Order By Not Working

    - by jwzk
    I'm running Mysql 5.0.77 and I'm pretty sure this query should work? SELECT * FROM purchases WHERE time_purchased BETWEEN '2010-04-15 00:00:00' AND '2010-04-18 23:59:59' ORDER BY time_purchased ASC, order_total DESC time_purchased is DATETIME, and an index. order_total is DECIMAL(10,2), and not an index. I want to order all purchases by the date (least to greatest), and then by the order total (greatest to least). So I would output similar to: 2010-04-15 $100 2010-04-15 $80 2010-04-15 $20 2010-04-16 $170 2010-04-16 $45 2010-04-16 $15 2010-04-17 $274 .. and so on. The output I am getting from that query has the dates in order correctly, but it doesn't appear to sort the order total column at all. Thoughts? Thanks.

    Read the article

  • Query - Trying to SUM one field based on content of another field

    - by ShaneL
    Table: DayOfWeek Enrollments Monday 35 Monday 12 Saturday 25 Tuesday 15 Monday 9 Tuesday 15 Basically I'm trying to sum the total enrolments for each day. so the Output will look like: DayOfWeek Enrollments Monday 56 Saturday 25 Tuesday 30 I've spent around 4 hours trying to work this out trying many many different ways but no luck. The problem I'm having is i can count how many enrollments for each day but can't have it aligned with the correct day when i run the query e.g. I want The total to be on the same line as the day it was calculated from. (I hope that is clear enough)

    Read the article

  • JS variable scope missunderstanding

    - by meo
    I have a little problem: slideHelpers.total = 4 for (i=1;i <= slideHelpers.total; i++) { $('<a href="#">' + i + '</a>').bind('click', function(){ alert('go to the ' + i + ' slide')}).appendTo('.slideaccess') } the alert gives out 5 what is logic, because when the function click triggers i is actually 5. But i would like to have the same i as in my <a> tag. What is the best way to handle this? I could put i in the data() of the <a> tag for example but i am sure there is a easier way.

    Read the article

  • How do I show the number of images attached to a post on the image attachment page?

    - by mattloak
    I use the image attachment page to show images attached to a post one by one, in a slideshow sort of affect. I'd like to be able to display the total number of images attached to the parent post and the number of the particular image that's being shown on any given attachment page so you see the picture and the words "Image 3 of 15" for example. I've played around with some different code and can get the total number of images to show on the post page, but when I insert the code on the attachment page template it always shows "1 of 1." I was having this problem a while ago and decided to re-address it, unfortunately I don't have the original code that I used and can't remember it. Anyone have any suggestions?

    Read the article

  • Getting confused why i dont get expected amount ?

    - by Stackfan
    I have 1 result and which i will receive in Bank account, Based on that account i have to Put a balance to user account. How can you find the Handling cost from total tried 491.50 / 0.95 = 517.36 which is wrong ? It should be 500.00 (to my expectation) User balance requires 500.00 When 500.00 selected he gets 5% discount There is a handling cost for this ex: 1) Discount: 500.00 - 5% = 475.00 2) Handling cost: (475.00 x 0.034) + 0.35 = 16.50 3) Total: 475.00 + 16.50 = 491.50 So problem is from 491.50, i have to find atleast handling cost to get promised Balance. Any solution ? Cant figure it out myself...

    Read the article

  • MySQL count/sum fields

    - by Conor H
    Hi There, What I am trying to achieve is a report on daily financial transactions. With my SQL query I would like to count the total number of cash transactions, the total cash value and the same for checks. I only want to do this for a specified date. Here is a snippet of the query that I am having trouble with. These sum and count commands are processing all the data in the table and not for the selected date. (SELECT SUM(amount) FROM TRANSACTION WHERE payment_type.name = 'cash') AS total_cash, (SELECT COUNT(*) FROM TRANSACTION WHERE payment_type.name = 'cash') AS total_cash_transactions Sorry if I havent posted enough detail as I haven't time. If you need more info just ask.. Cheers.

    Read the article

  • Get values from HTML in a multidimensional array and calculate values using PHP

    - by Frank Nwoko
    I have searched but could not get solution on this issue. I am working on an application which will generate unknown number of items and have users select the quantity from a drop down against each item. Eg. Item(s) | price | Select qty Rice 23 3 Beans 22 4 Eggs 52 5 ... ... ... unknown Please, how can I capture the above in an array and also calculate the total value for all selected items and corresponding fees? I have the following HTML code: <form id='form1' name='form1' method='post' action='item_calc.php'> <?php ..... while($t_row = mysql_fetch_assoc($get_items)) { echo "<p><label>$t_row['$item_name'] <input type='text' READONLY name='item_price[]' value='$t_row['$item_price']' /></label> <input type='text' READONLY name='item_fees[]' value='$t_row['$item_fee']' /> <select name="item_qty"> <option value="1"> <option value="2"> <option value="3"> <option value="4"> <option value="5"> </select> </p><p>"; } echo "<label><input type='submit' name='submit' value='Submit' /></label></p> </form>"; Please, how can I get item_price[] + item_fees[] * item_qty for all selected items? This is what I have tried: for ($i = 0; $i < count($_POST['item_price']); $i++) { // Do something here with $_POST['checkbx'][$i] foreach ($_POST['item_fees'] as $tkey => $tvalue) { //echo "Key: $tkey; Value: $tvalue<br>"; } foreach ($_POST['item_price'] as $pkey => $pvalue) { //echo "Key: $pkey; Value: $pvalue<br>"; } $total = $tvalue + $pvalue; } echo $total;

    Read the article

  • Trying to get unique records with MySQL

    - by Joshmattvander
    I have a query that is looking at a 'page_views' table. And I so far have the ability to get the total views by day. However, I am having an issue with getting unique views by day. The column I am testing against is user_id... Here's the query I have for total views. SELECT site_id, CONCAT(month(created_at) , '-', day(created_at), '-' , year(created_at)) as created_at_date, COUNT(*) as total_results FROM page_views GROUP BY day(created_at) I can't figure out the logic to just get the unique views, by day based on the user_id column though.

    Read the article

  • JQUERY: Multiplying input elements select box and radio boxes and hidden inputs

    - by Andrew Tan
    Evening, I'm tyring to multiply different input elements but for some reason it's giving me a NAND error. As the user selects, check or modify the values of any element. This should change the total amount. http://jsfiddle.net/aQ5K8/ <select name="select"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <input name="radio" type="radio" id="radio" value="10" tvalue="100" /> <input name="radio" type="radio" id="radio" value="20" tvalue="200" /> <label id="Total"></label> Also if you take a look at the jsfiddle code i have tvalue=100 and the other is =200 as a custom attributes, how would I access that instead of accessing the regular html value. Thank you.

    Read the article

  • In SQL, how can I count the number of values in a column and then pivot it so the column becomes the

    - by Josh Yeager
    I have a survey database with one column for each question and one row for each person who responds. Each question is answered with a value from 1 to 3. Id Quality? Speed? -- ------- ----- 1 3 1 2 2 1 3 2 3 4 3 2 Now, I need to display the results as one row per question, with a column for each response number, and the value in each column being the number of responses that used that answer. Finally, I need to calculate the total score, which is the number of 1's plus two times the number of 2's plus three times the number of threes. Question 1 2 3 Total -------- -- -- -- ----- Quality? 0 2 2 10 Speed? 2 1 1 7 Is there a way to do this in set-based SQL? I know how to do it using loops in C# or cursors in SQL, but I'm trying to make it work in a reporting tool that doesn't support cursors.

    Read the article

  • ORA-00937 error during select subquery

    - by RedRaven
    I am attempting to write a query that returns the the number of employees, the average salary, and the number of employees paid below the average. The query I have so far is: select trunc(avg(salary)) "Average Pay", count(salary) "Total Employees", ( select count(salary) from employees where salary < (select avg(salary) from employees) ) UnderPaid from employees; But when I run this I get the ora-00937 error in the subquery. I had thought that maybe the "count" function is what is causing the issue, but even running a simpler sub query such as: select trunc(avg(salary)) "Average Pay", count(salary) "Total Employees", ( select avg(salary) from employees ) UnderPaid from employees; still returns the same error. As both AVG and COUNT seem to be aggregate functions, I'm not sure why I'm getting the error? Thanks

    Read the article

  • Ruby: totalling amounts

    - by Michael
    I have a Donation.rb model with an amount column that takes an integer. I want to sum all the individual donations together and show the total on the home page. In the home_controller, I'm doing @donations = Donation.all and then in the view I do <% sum = 0 %> <% @donations.each do |donation| %> <%= sum += donation.amount if donation.amount? %> <% end %> The problem is that this is printing the running sum each time a new donation is added to it. I just want the total sum at the end after they've all been added together.

    Read the article

< Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >