Search Results

Search found 6988 results on 280 pages for 'if else statement'.

Page 40/280 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • How to write a JOIN statement to combine data from disparate tables

    - by Amarundo
    I have the following 2 procedures that I use as my source for a report. As of now, I'm presenting 2 different tables in my SQL Server Reporting Services 2008 R2 report, because it doesn't let me put them together as they belong to 2 different data sets. I want to present them in a single table, but I have not been successful trying to use JOIN here. How do I do that? NOTE: cName in IAgentQueueStats corresponds to UserId in AgentActivityLog. /*** Aggregate values for Call Center Agents for calls, talk and hold time ***/ /*** The detail/row values is per 30-minute interval ***/ ALTER PROCEDURE [dbo].[sp_IAgentQueueStats_OnlyCalls_Grouped] @p_StartDate datetime, @p_EndDate datetime, @p_Agents varchar(8000) AS SELECT [cName] ,sum([nAnswered]) SumNAnswered ,sum([nAnsweredAcd]) SumNAnsweredAcd ,sum([tTalkAcd]) SumTTalkAcd ,sum([nHoldAcd]) SumNHoldAcd ,sum([tHoldAcd]) SumTHoldAcd ,sum([tAcw]) SumTAcw FROM [I3_IC].[dbo].[IAgentQueueStats] WHERE dIntervalStart between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate) AND CHARINDEX ( cName ,@p_Agents)> 0 AND cReportGroup <> '*' AND cHKey3 = '*' and cHKey4 ='*' AND nEnteredAcd > 0 AND cReportGroup <> 'CCFax Email' GROUP BY cName And here is the second one: /*** Aggregate values for Call Center Agents for status/activity time ***/ /*** The detail/row values is per start-time/end-time ***/ ALTER PROCEDURE [dbo].[sp_AgentActivity_Grouped] @p_StartDate datetime, @p_EndDate datetime, @p_Agents varchar(8000) AS SELECT [UserId],[StatusCategory],SUM([StateDuration]) [StatusDuration] FROM ( SELECT [UserId] ,[StatusGroup] ,[StatusKey] , CASE [StatusKey] WHEN 'Available' THEN 'Productive' WHEN 'Follow Up' THEN 'Productive' WHEN 'Campaign Call' THEN 'Productive' WHEN 'Awaiting Callback' THEN 'Productive' WHEN 'In a Meeting' THEN 'Not Your Fault' WHEN 'Project Work' THEN 'Not Your Fault' WHEN 'At a Training Session'THEN 'Not Your Fault' WHEN 'System Issues' THEN 'Not Your Fault' WHEN 'Test' THEN 'Not Your Fault' WHEN 'At Lunch' THEN 'Non Productive' WHEN 'Available, Forward' THEN 'Non Productive' WHEN 'Available, Follow-Me' THEN 'Non Productive' WHEN 'At Play' THEN 'Non Productive' WHEN 'AcdAgentNotAnswering' THEN 'Non Productive' WHEN 'Do Not Disturb' THEN 'Non Productive' WHEN 'Available, No ACD' THEN 'Non Productive' WHEN 'Away from desk' THEN 'Non Productive' ELSE [StatusKey] END StatusCategory ,stateduration FROM [I3_IC].[dbo].[AgentActivityLog] WHERE [StatusDateTime] between @p_StartDate and DATEADD(s, 86400-1, @p_EndDate) AND CHARINDEX ( [UserId] ,@p_Agents)> 0 AND [StatusKey] not in ('Gone Home','Out of the Office','On Vacation','Out of Town') ) a GROUP BY [UserId],[StatusCategory] ORDER BY [UserId], [StatusCategory] desc BTW, if I take some time to comment/reply on your posts, it's not lack of interest, but of understanding...

    Read the article

  • php while loop throwing a error over a $var < 10 statement

    - by William
    Okay, so for some reason this is giving me a error as seen here: http://prime.programming-designs.com/test_forum/viewboard.php?board=0 However if I take away the '&& $cur_row < 10' it works fine. Why is the '&& $cur_row < 10' causing me a problem? $sql_result = mysql_query("SELECT post, name, trip, Thread FROM (SELECT MIN(ID) AS min_id, MAX(ID) AS max_id, MAX(Date) AS max_date FROM test_posts GROUP BY Thread ) t_min_max INNER JOIN test_posts ON test_posts.ID = t_min_max.min_id WHERE Board=".$board." ORDER BY max_date DESC", $db); $num_rows = mysql_num_rows($sql_result); $cur_row = 0; while($row = mysql_fetch_row($sql_result) && $cur_row < 10) { $sql_max_post_query = mysql_query("SELECT ID FROM test_posts WHERE Thread=".$row[3].""); $post_num = mysql_num_rows($sql_max_post_query); $post_num--; $cur_row++; echo''.$cur_row.'<br/>'; echo'<div class="postbox"><h4>'.$row[1].'['.$row[2].']</h4><hr />' .$row[0]. '<br /><hr />[<a href="http://prime.programming-designs.com/test_forum/viewthread.php?thread='.$row[3].'">Reply</a>] '.$post_num.' posts omitted.</div>'; }

    Read the article

  • MySQL- complex data query in a single statement

    - by yoda
    Hi, Consider the following structure : Ignore the table user_token. Now, imagine that you need to get all the roles related to an user, wich may be through it's related groups or directly related to him. In case the same role appears related to a group and the user directly, the role related to the user will prevail over the role given by the group. Is there any chance this could be done in a single query? Cheers!

    Read the article

  • Improve a regex statement in order to be as efficient as it can be

    - by user551625
    I have a PHP program that, at some point, needs to analyze a big amount of HTML+javascript text to parse info. All I want to parse needs to be in two parts. Seperate all "HTML goups" to parse Parse each HTML group to get the needed information. In the 1st parse it needs to find: <div id="myHome" And start capturing after that tag. Then stop capturing before <span id="nReaders" And capture the number that comes after this tag and stop. In the 2nd parse use the capture nº 1 (0 has the whole thing and 2 has the number) from the parse made before and then find . I already have code to do that and it works. Is there a way to improve this, make it easier for the machine to parse? preg_match_all('%<div id="myHome"[^>]>(.*?)<span id="nReaders[^>]>([0-9]+)<"%msi', $data, $results, PREG_SET_ORDER); foreach($results AS $result){ preg_match_all('%<div class="myplacement".*?[.]php[?]((?:next|before))=([0-9]+).*?<tbody.*?<td[^>]>.*?[0-9]+"%msi', $result[1], $mydata, PREG_SET_ORDER); //takes care of the data and finish the program Note: I need this for a freeware program so it must be as general as possible and, if possible, not use php extensions ADD: I ommitted some parts here because I didn't expect for answers like those. There is also a need to parse text inside one of the tags that is in the document. It may be the 6th 7th or 8th tag but I know it is after a certain tag. The parser I've checked (thx profitphp) does work to find the script tag. What now? There are more than 1 tag with the same class. I want them all. But I want only with also one of a list of classes..... Where can I find instructions and demos and limitations of DOM parsers (like the one in http://simplehtmldom.sourceforge.net/)? I need something that will work on, at least, a big amount of free servers.

    Read the article

  • Constructing an if, if else, else statement

    - by Luke
    /* Errors exist, have user correct them */ if($form->num_errors > 0) { return 1; //Errors with form } /* No errors, add the new account to the */ else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype)) { $database->addLeagueTable(); $_SESSION['players'] == $subplayers; $comp_name == '$format_$game_$name_$season'; $_SESSION['comp_name'] == $comp_name; return 0; //New user added succesfully } else { return 2; //Registration attempt failed } At the moment this isn't doing any of these things\: $database->addLeagueTable(); $_SESSION['players'] == $subplayers; $comp_name == '$format_$game_$name_$season'; $_SESSION['comp_name'] == $comp_name; Is there a better way to do this?

    Read the article

  • Python for statement giving an Invalid Syntax error with list

    - by Cold Diamondz
    I have some code in which is throwing an error (I'm using repl.it) import random students = ['s1:0','s2:0','s3:0'] while True: print'\n'*50 print'Ticket Machine'.center(80) print'-'*80 print'1. Clear Student Ticket Values'.center(80) print'2. Draw Tickets'.center(80) menu = raw_input('-'*80+'\nChoose an Option: ') if menu == '1': print'\n'*50 print'CLEARED!' students = ['s1:0','s2:0','s3:0'] raw_input('Press enter to return to the main menu!') elif menu == '2': tickets = [] print'\n'*50 times = int(raw_input('How many tickets to draw? ') for a in students: for i in range(a.split(':')[1]): tickets.append(a.split(':')[0]) for b in range(1,times+1): print str(b) + '. ' + random.choice(tickets) else: print'\n'*50 print'That was not an option!' raw_input('Press enter to return to the main menu!') But it is throwing this error: File "<stdin>", line 19 for a in students: ^ SyntaxError: invalid syntax I am planning on using this in a class, but I can't use it until the bug is fixed, also, student names have been removed for privacy reasons.

    Read the article

  • How to check if element have any text

    - by user3611403
    How can I check, if element does have any text? I have found some code, but it does not work. I need to do something like this: If element has text, write this, if not, write something else. if (!$('.flexslider .item:first p').text().trim().length) { var text = $(this).text(); $('.text-anim-sphone').html(text); } else { $('.text-anim-sphone').html('welcome'); }

    Read the article

  • About import statement in Java

    - by user198729
    test.java: import javax.media; Which directories are javax.media searched from? I suppose those in CLASSPATH specified by javac -cp will of course be searched. But will it also search in the directory where test.java locates? And are there any other possible places that will be searched?

    Read the article

  • switch statement with returns -- code correctness

    - by houbysoft
    Hi, let's say I have code in C with approximately this structure: switch (something) { case 0: return "blah"; break; case 1: case 4: return "foo"; break; case 2: case 3: return "bar"; break; default: return "foobar"; break; } Now obviously, the "break"s are not necessary for the code to run correctly, but it sort of looks like bad practice if I don't put them there to me. What do you think? Is it fine to remove them? Or would you keep them for increased "correctness"?

    Read the article

  • if statement inside array : codeigniter

    - by ahmad
    Hello , I have this function to edit all fields that come from the form and its works fine .. function editRow($tableName,$id) { $fieldsData = $this->db->field_data($tableName); $data = array(); foreach ($fieldsData as $key => $field) { $data[ $field->name ] = $this->input->post($field->name); } $this->db->where('id', $id); $this->db->update($tableName, $data); } now I want to add a condition for Password field , if the field is empty keep the old password , I did some thing like that : function editRow($tableName,$id) { $fieldsData = $this->db->field_data($tableName); $data = array(); foreach ($fieldsData as $key => $field) { if ($data[ $field->name ] == 'password' && $this->input->post('password') == '' ) { $data[ 'password' ] => $this->input->post('hide_password'), //'password' => $this->input->post('hide_password'), } else { $data[ $field->name ] => $this->input->post($field->name) } } $this->db->where('id', $id); $this->db->update($tableName, $data); } but I get error ( Parse error: syntax error, unexpected T_DOUBLE_ARROW in ... ) Html , some thing like this : <input type="text" name="password" value=""> <input type="hidden" name="hide_password" value="$row->$password" /> umm , any help ? thanks ..

    Read the article

  • A SELECT statement for Mysql

    - by Hossein
    I have this table: id,bookmarkID,tagID I want to fetch the top N bookmarkIDs for a given list of tags. Does anyone know a very fast solution for this? the table is quite large(12 million records) I am using MySql

    Read the article

  • Dealing with big IF statements in PHP

    - by Industrial
    Hi everyone, Is there any good alternative for the plain if statements in PHP? I know about switch, but I'll guess that there's some more refined alternative out there that comes handy when working with really big if statements. Thanks a lot,

    Read the article

  • Suffix if statement

    - by Aardschok
    I was looking for a way to add a suffix to jointchain in Maya. The jointchain has specific naming so I create a list with the names they need to be. The first chain has "_1" as suffix, result: R_Clavicle_1|R_UpperArm_1|R_UnderArm_1|R_Wrist_1 When I create the second this is the result: R_Clavicle_2|R_UpperArm_1|R_UnderArm_1|R_Wrist_1 The code: DRClavPos = cmds.xform ('DRClavicle', q=True, ws=True, t=True) DRUpArmPos = cmds.xform ('DRUpperArm', q=True, ws=True, t=True) DRUnArmPos = cmds.xform ('DRUnderArm', q=True, ws=True, t=True) DRWristPos = cmds.xform ('DRWrist', q=True, ws=True, t=True), cmds.xform('DRWrist', q=True, os=True, ro=True) suffix = 1 jntsA = cmds.ls(type="joint", long=True) while True: jntname = ["R_Clavicle_"+str(suffix),"R_UpperArm_"+str(suffix),"R_UnderArm_"+str(suffix),"R_Wrist_"+str(suffix)] if jntname not in jntsA: cmds.select (d=True) cmds.joint ( p=(DRClavPos)) cmds.joint ( p=(DRUpArmPos)) cmds.joint ( 'joint1', e=True, zso=True, oj='xyz', radius=0.5, n=jntname[0]) cmds.joint ( p=(DRUnArmPos)) cmds.joint ( 'joint2', e=True, zso=True, oj='xyz', radius=0.5, n=jntname[1]) cmds.joint ( p=(DRWristPos[0])) cmds.joint ( 'joint3', e=True, zso=True, oj='xyz', radius=0.5, n=jntname[2]) cmds.rename ('joint4', jntname[3]) cmds.select ( cl=True) break else: suffix + 1 I tried adding +1 in jntname which resulted in a good second chain but the third chain had "_2" after R_Clavicle_3 The code, in my eyes should work. Can anybody point me in the correct direction :)

    Read the article

  • Null Value Statement

    - by Sam
    Hi All, I have created a table called table1 and it has 4 columns named Name,ID,Description and Date. I have created them like Name varchar(50) null, ID int null,Description varchar(50) null, Date datetime null I have inserted a record into the table1 having ID and Description values. So Now my table1 looks like this: Name ID Description Date Null 1 First Null One of them asked me to modify the table such a way that The columns Name and Date should have Null values instead of Text Null. I don't know what is the difference between those I mean can anyone explain me the difference between these select statements: SELECT * FROM TABLE1 WHERE NAME IS NULL SELECT * FROM TABLE1 WHERE NAME = 'NULL' SELECT * FROM TABLE1 WHERE NAME = ' ' Can anyone explain me?

    Read the article

  • If not following correct procedure?

    - by ct2k7
    Hi, I'm working on a Content Management System, and so far so good. I'm trying to get the system to work with a maintenance mode system. This is the code in the script to display the maintenance stuff: if ($maintenance['value'] == "1") {?> <div id="content"> <div id="errmsg"> <?php echo $maintenance['notes']; ?> </div> </div> <? } else {?> <h1><?php echo $title; ?></h1> <hr /><br /> <div id="content"> <?php echo $contents; if (!$content) { include ('includes/error/404.php');}?> </div> <? } ?> I can verify that the $maintenance['value'] variable is working as it should, but this portion o the script isn't working as it should. The value is currently set to 1, but it still displays the stuff in the else. Any ideas?

    Read the article

  • Fill in missing values in a SELECT statement

    - by benjamin button
    If i have a table with two fields.customer id and order. let's say i have in total order ID 1,2,3,4 all the customer can have all the four orders.like below 1234 1 1234 2 1234 3 1234 4 3245 3 3245 4 5436 2 5436 4 you can see above that 3245 customer doesnt have order id 1 and 2. how could i print in the query output like 3245 1 3245 2 5436 1 5436 3 EDIT: i dont have order table but i have list of order's like we can hard code it in the query(1,2,3,4) i dont have an orders table.

    Read the article

  • Infinite sharing system (PHP/MySQLi)

    - by Toine Lille
    I'm working on a discount system for whichever customer shares a product and brings in new customers. Each unique visit = $0.05 off, each new customer = $0.50 off (it's a cheap product so yeah, no big numbers). When a new customer shares the site, the customer initially responsible for the new customer (if any) will get half of the new customer's discount as well. The initial customer would get a fourth for the next level and the new customer half of that, etc, creating a tree or pyramid that way that could be infinite. Initial customer ($1.35 discount: 2 new+3 visits + half of 1 new+2 visits) Visitor ($0) Visitor ($0) New customer ($0.60) Visitor ($0) Visitor ($0) Newer customer ($0) New customer ($0) Visitor ($0) The customers are saved along with their IP addresses (bin2hex(inet_pton)) in a database table (customers) with info like a unique id, e-mail address and first date/time the purchased a product (= time of registration). The shares are saved in a separate table within the same database (sharing). Each unique IP addresses that visits the site creates a new row featuring the IP address (also saved as bin2hex(inet_pton)), the id of the customer who shared it and the date/time of the visit. Sharing goes via URL, featuring a GET element containing the customer's id. Visits and new customers overlap, as visits will always occur before the new customer does. That's fine. The date/times are used just to make it a little more secure (I also use the IP along with cookies to see if people cheat the system). If an IP is already in the sharing or customer tables, it does not count and will not create a new entry. Now the problem is, how to make the infinity happen and apply the different values to it? That's all I'd need to know. It needs to calculate the discount for each customer separately, but also allow for monitoring altogether (though that's just a matter of passing all ID's through it). I figured I'd start (after the database connection) with $stmt = $con->prepare('SELECT ip,datetime FROM sharing WHERE sender=?'); $stmt->bind_param('i',$customerid); $stmt->execute(); $stmt->store_result(); $discount = $discount + ($stmt->num_rows * 0.05); $stmt->bind_result($ip,$timeofsharing); to translate all the visits to $0.05 of discount each. To check for the new customers that came from these visits, I wrote the following: while ($sql->fetch()) { $stmt2 = $con->prepare("SELECT datetime FROM users WHERE ip=?"); $stmt2->bind_param('s',$ip); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($timeofpurchase); Followed by a little more security comparing the datetimes: while ($stmt2->fetch()) { if (strtotime($timeofpurchase) < strtotime($timeofsharing)) { $discount = $discount + $0.50; } But this is just for the initial customer's direct results. If I'd want to check for the next level, I'd basically have to put the exact same check and loop in itself, checking each new customer the initial customer they brought to the site, and then for the next level again to check all of the newer customers, etc, etc. What to do? / Where to go? / What would be the correct practice for this? Thanks!

    Read the article

  • iPhone - Using sql database - insert statement failing

    - by Satyam svv
    Hi, I'm using sqlite database in my iphone app. I've a table which has 3 integer columns. I'm using following code to write to that database table. -(BOOL)insertTestResult { NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectory = [paths objectAtIndex:0]; NSString* dataBasePath = [documentsDirectory stringByAppendingPathComponent:@"test21.sqlite3"]; BOOL success = NO; sqlite3* database = 0; if(sqlite3_open([dataBasePath UTF8String], &database) == SQLITE_OK) { BOOL res = (insertResultStatement == nil) ? createStatement(insertResult, &insertResultStatement, database) : YES; if(res) { int i = 1; sqlite3_bind_int(insertResultStatement, 0, i); sqlite3_bind_int(insertResultStatement, 1, i); sqlite3_bind_int(insertResultStatement, 2, i); int err = sqlite3_step(insertResultStatement); if(SQLITE_ERROR == err) { NSAssert1(0, @"Error while inserting Result. '%s'", sqlite3_errmsg(database)); success = NO; } else { success = YES; } sqlite3_finalize(insertResultStatement); insertResultStatement = nil; } } sqlite3_close(database); return success;} The command sqlite3_step is always giving err as 19. I'm not able to understand where's the issue. Tables are created using following queries: CREATE TABLE [Patient] (PID integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,PFirstName text NOT NULL,PLastName text,PSex text NOT NULL,PDOB text NOT NULL,PEducation text NOT NULL,PHandedness text,PType text) CREATE TABLE PatientResult(PID INTEGER,PFreeScore INTEGER NOT NULL,PForcedScore INTEGER NOT NULL,FOREIGN KEY (PID) REFERENCES Patient(PID)) I've only one entry in Patient table with PID = 1 BOOL createStatement(const char* query, sqlite3_stmt** stmt, sqlite3* database){ BOOL res = (sqlite3_prepare_v2(database, query, -1, stmt, NULL) == SQLITE_OK); if(!res) NSLog( @"Error while creating %s => '%s'", query, sqlite3_errmsg(database)); return res;}

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >