Search Results

Search found 17734 results on 710 pages for 'values'.

Page 87/710 | < Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >

  • sql-server: how can I list distinct value of table in a single row, separated by comma

    - by RedsDevils
    I have the following Table: CREATE TABLE TEMP (ID INT,SEGMENT CHAR(1),SEGOFF INT,CHECKED SMALLDATETIME) INSERT INTO TEMP VALUES (1,'A',0,'2009-05-01') INSERT INTO TEMP VALUES (2,'B',1,'2009-05-01') INSERT INTO TEMP VALUES (3,'C',0,'2009-05-01') INSERT INTO TEMP VALUES (4,'A',0,'2009-05-02') INSERT INTO TEMP VALUES (5,'B',2,'2009-05-02') INSERT INTO TEMP VALUES (6,'C',1,'2009-05-02') INSERT INTO TEMP VALUES (7,'A',1,'2009-05-03') INSERT INTO TEMP VALUES (8,'B',0,'2009-05-03') INSERT INTO TEMP VALUES (9,'C',2,'2009-05-03') I would like to show Distinct SEGEMENT in Single row separated by comma (e.g: A,B,C) I try as Follow: DECLARE @SEGMENTList varchar(100) SELECT @SEGMENTList = COALESCE(@SEGMENTList + ', ', '') + SEGMENT FROM TEST SELECT @SEGMENTList It shows A, B, C, A, B, C, A, B, C What do I need to change my query? Thanks all!

    Read the article

  • Getting data from a ListView into an array

    - by Joe
    I have a ListView control on my form set up like this in details mode: What I would like to do, is get all the values of the data cells when the user presses the Delete booking button. So using the above example, my array would be filled with this data: values(0) = "asd" values(1) = "BS1" values(2) = "asd" values(3) = "21/04/2010" values(4) = "2" This is my code so far: Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim items As ListView.SelectedListViewItemCollection = _ Me.ManageList.SelectedItems Dim item As ListViewItem Dim values(0 To 4) As String Dim i As Integer = 0 For Each item In items values(i) = item.SubItems(i).Text i = i + 1 Next End Sub But only values(0) gets filled with the first data cell of the selection (in this case "asd") and the rest of the array entries are blank. I have confirmed this with a breakpoint and checked the array entries myself. I'm REALLY lost on this, and have been trying for about an hour now. Any help would be appreciated, thanks :) Also please note that there can only be one row selection at once. Thanks.

    Read the article

  • select mysql data using MAX

    - by JPro
    I have a testdata like this: DROP TABLE SELECT_PASS; CREATE TABLE SELECT_PASS(ID INT(20),TESTCASE VARCHAR(20),RESULT VARCHAR(20)); INSERT INTO SELECT_PASS VALUES(1,"TC1","PASS"); INSERT INTO SELECT_PASS VALUES(2,"TC2","PASS"); INSERT INTO SELECT_PASS VALUES(3,"TC3","INCONC"); INSERT INTO SELECT_PASS VALUES(4,"TC1","FAIL"); INSERT INTO SELECT_PASS VALUES(5,"TC21","FAIL"); INSERT INTO SELECT_PASS VALUES(6,"TC4","PASS"); INSERT INTO SELECT_PASS VALUES(7,"TC3","PASS"); INSERT INTO SELECT_PASS VALUES(8,"TC2","PASS"); INSERT INTO SELECT_PASS VALUES(9,"TC1","TIMEOUT"); SELECT TESTCASE, MAX(RESULT) FROM SELECT_PASS GROUP BY TESTCASE; The resultset I get is : TC1 TIMEOUT TC2 PASS TC21 FAIL TC3 PASS TC4 PASS Basically I want to see those testcases which never passed. Any way to do it? Thanks.

    Read the article

  • WPF AutoCompleteBox with ability to add new values to list.

    - by WillH
    Hi, I would like to use autocompletebox with a list of values, but also add new values to the list if a user enters one that isn't present. I currently have a string property in my view model called 'Comment'. Currently this is bound to a textbox in the view - user types a comment and the view model is updated. Simple. To save time, my customer would like it to autocomplete from previous values, so the way I thought to do this is something like: ViewModel public string Comment; public ObservableCollection<string> CommentsList { ... } (populate the CommentsList when the viewmodel is created) View <AutoCompleteComboBox ItemsSource="{Binding CommentsList}" SelectedItem="{Binding Comment, Mode=TwoWay/> So when the user selects a value, it saves the value in the Comment property. This works fine if the user selects an item in the list, but if the user types in a new value, the comment property is not updated (it is null because the selected item was not in the list). Is this possible with autocompletebox? Thanks in advance, Will

    Read the article

  • iPhone:How to make an integer array and store values in Obj-C?

    - by user187532
    Hi, I want to know a simple thing, which i couldn't get it is that i want to store 10 values in an integer array dynamically and then i have to check that stored values and compared with the current values whether it is same or not in some other condition. Initially i tried same like C array, int temp[10], but seems to be that is not possible to set and get method, then i tried NSNumber like below, In AppDelagate file, NSMutableArray *reqID; @property (nonatomic,readwrite) NSMutableArray * reqID; @synthesize reqID; ........................ ........................ ........................ In Some other file, int rd = (1+arc4random() % [arr count]); [myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]]; then i need to check, for (int i=0; i<10; i++) { NSUInteger anInt = [[amyDelagate.reqID objectAtIndex:i] unsignedIntegerValue]; if ( anInt==rd ) { rd = (1+arc4random() % [arr count]); break; } } [myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]]; But it doesn' work as expected, i.e array value doesn't give proper value. i don't know how to use integer array in Obj-C and handle it to access later etc. Could someone please explian me?

    Read the article

  • WPF/Silverlight AutoCompleteBox with ability to add new values to list.

    - by WillH
    Hi, I would like to use autocompletebox with a list of values, but also add new values to the list if a user enters one that isn't present. I currently have a string property in my view model called 'Comment'. Currently this is bound to a textbox in the view - user types a comment and the view model is updated. Simple. To save time, my customer would like it to autocomplete from previous values, so the way I thought to do this is something like: ViewModel public string Comment; public ObservableCollection<string> CommentsList { ... } (populate the CommentsList when the viewmodel is created) View <AutoCompleteComboBox ItemsSource="{Binding CommentsList}" SelectedItem="{Binding Comment, Mode=TwoWay/> So when the user selects a value, it saves the value in the Comment property. This works fine if the user selects an item in the list, but if the user types in a new value, the comment property is not updated (it is null because the selected item was not in the list). Is this possible with autocompletebox? Thanks in advance, Will

    Read the article

  • How to invalidate cache when benchmarking?

    - by Michael Buen
    I have this code, that when swapping the order of UsingAs and UsingCast, their performance also swaps. using System; using System.Diagnostics; using System.Linq; using System.IO; class Test { const int Size = 30000000; static void Main() { object[] values = new MemoryStream[Size]; UsingAs(values); UsingCast(values); Console.ReadLine(); } static void UsingCast(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { if (o is MemoryStream) { var m = (MemoryStream)o; sum += (int)m.Length; } } sw.Stop(); Console.WriteLine("Cast: {0} : {1}", sum, (long)sw.ElapsedMilliseconds); } static void UsingAs(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { if (o is MemoryStream) { var m = o as MemoryStream; sum += (int)m.Length; } } sw.Stop(); Console.WriteLine("As: {0} : {1}", sum, (long)sw.ElapsedMilliseconds); } } Outputs: As: 0 : 322 Cast: 0 : 281 When doing this... UsingCast(values); UsingAs(values); ...Results to this: Cast: 0 : 322 As: 0 : 281 When doing just this... UsingAs(values); ...Results to this: As: 0 : 322 When doing just this: UsingCast(values); ...Results to this: Cast: 0 : 322 Aside from running them independently, how to invalidate the cache so the second code being benchmarked won't receive the cached memory of first code? Benchmarking aside, just loved the fact that modern processors do this caching magic :-)

    Read the article

  • Import MySQL file in PHP

    - by Cudos
    I have a MySQL file which I want to import via PHP 5. In the name of user friendliness the user should not use tools like PHPmyadmin etc. Just hit a button and the file will get imported. I have already created code to upload the file to a location on the server. The file looks like this: INSERT INTO products VALUES ('', '0', '10', '', '1', 'be34112', '4536.jpg', '','','','0'); SET @master_id = LAST_INSERT_ID(); INSERT INTO products_description VALUES ('', '1', @master_id, '1', 'Kjole', '', 'beskrivelse', '2000', '25', 'kjole.xml', '', '', ''); INSERT INTO products_to_categories VALUES ('',@master_id,'5'); INSERT INTO products VALUES ('', @master_id, '10', '12', '1', 'be34112', '4536.jpg', '200','','','0'); SET @variant_id = LAST_INSERT_ID(); INSERT INTO products_description VALUES ('', '1', @variant_id, '1', 'Kjole', '', 'beskrivelse', '2000', '25', 'kjole.xml', '', '', ''); INSERT INTO options_to_products VALUES ('', @variant_id, '1', '1'); INSERT INTO options_to_products VALUES ('', @variant_id, '', '2'); INSERT INTO products VALUES ('', @master_id, '20', '17', '1', 'be34113', '4537.jpg', '200','','','0'); SET @variant_id = LAST_INSERT_ID(); INSERT INTO products_description VALUES ('', '1', @variant_id, '1', 'Kjole', '', 'beskrivelse æøå ÆØÅ & íjj´¨¨¨¨fdfd""', '3000', '25', 'kjole.xml', '', '', ''); INSERT INTO options_to_products VALUES ('', @variant_id, '1', ''); INSERT INTO options_to_products VALUES ('', @variant_id, '', '4');

    Read the article

  • What is a faster way of merging the values of this Python structure into a single dictionary?

    - by jcoon
    I've refactored how the merged-dictionary (all_classes) below is created, but I'm wondering if it can be more efficient. I have a dictionary of dictionaries, like this: groups_and_classes = {'group_1': {'class_A': [1, 2, 3], 'class_B': [1, 3, 5, 7], 'class_c': [1, 2], # ...many more items like this }, 'group_2': {'class_A': [11, 12, 13], 'class_C': [5, 6, 7, 8, 9] }, # ...and many more items like this } A function creates a new object from groups_and_classes like this (the function to create this is called often): all_classes = {'class_A': [1, 2, 3, 11, 12, 13], 'class_B': [1, 3, 5, 7, 9], 'class_C': [1, 2, 5, 6, 7, 8, 9] } Right now, there is a loop that does this: all_classes = {} for group in groups_and_classes.values(): for c, vals in group.iteritems(): for v in vals: if all_classes.has_key(c): if v not in all_classes[c]: all_classes[c].append(v) else: all_classes[c] = [v] So far, I changed the code to use a set instead of a list since the order of the list doesn't matter and the values need to be unique: all_classes = {} for group in groups_and_classes.values(): for c, vals in group.iteritems(): try: all_classes[c].update(set(vals)) except KeyError: all_classes[c] = set(vals) This is a little nicer, and I didn't have to convert the sets to lists because of how all_classes is used in the code. Question: Is there a more efficient way of creating all_classes (aside from building it at the same time groups_and_classes is built, and changing everywhere this function is called)?

    Read the article

  • Easiest way to plot values as symbols in scatter plot?

    - by AllenH
    In an answer to an earlier question of mine regarding fixing the colorspace for scatter images of 4D data, Tom10 suggested plotting values as symbols in order to double-check my data. An excellent idea. I've run some similar demos in the past, but I can't for the life of me find the demo I remember being quite simple. So, what's the easiest way to plot numerical values as the symbol in a scatter plot instead of 'o' for example? Tom10 suggested plt.txt(x,y,value)- and that is the implementation used in a number of examples. I however wonder if there's an easy way to evaluate "value" from my array of numbers? Can one simply say: str(valuearray) ? Do you need a loop to evaluate the values for plotting as suggested in the matplotlib demo section for 3D text scatter plots? Their example produces: However, they're doing something fairly complex in evaluating the locations as well as changing text direction based on data. So, is there a cute way to plot x,y,C data (where C is a value often taken as the color in the plot data- but instead I wish to make the symbol)? Again, I think we have a fair answer to this- I just wonder if there's an easier way?

    Read the article

  • How do I flatten an associative array into an array with only values in PHP?

    - by aalaap
    I have an array that has keys and values. For eg: Array ( [name] => aalaap [age] => 29 [location] => mumbai ) I want to convert the keys from this into values, but I want the values to apear right after the keys. For eg: Array ( [0] => name [1] => aalaap [2] => age [3] => 29 [4] => location [5] => mumbai ) I can easily write an iteration function that will do this... for eg: array_flatten($arr) { foreach ($arr as $arrkey => $arrval) { $arr_new[] = $arrkey; $arr_new[] = $arrval; } return $arr_new; } ...but I'm trying to find out if there's any way this can be accomplished using array_combine, array_keys, array_values and/or array_merge, preferably in one, so i don't need to use a custom function. Is there?

    Read the article

  • display values within stacked boxes of rowstacked histograms in gnuplot?

    - by gojira
    I am using gnuplot (Version 4.4 patchlevel 2) to generate rowstacked histograms, very similar to the example called "Stacked histograms by percent" from the gnuplot demo site at http://www.gnuplot.info/demo/histograms.html I want to display the values of each stacked box within it. I.e. I want to display the actual numerical value (in percent and/or the absolute number) of each box. How can I do that?

    Read the article

  • Need to exclude results in a MySQL query where two table fields are not of certain values (brain far

    - by DondeEstaMiCulo
    I don't know if I'm just burnt out and can't think, or what... But I can't seem to make this work right... (We're using MySQL 5.1...) I have two tables which have some transactional stuff stored in them. There will be many records per user_id in each table. Table1 and Table2 have a one-to-one relationship with each other. I want to pull records from both tables, but I want to exclude records which have certain values in both tables. I don't care if they both don't have these values, or if just one does, but both tables should not have both values. (Does this make any sense? lol) For example: SELECT t1.id, t1.type, t2.name FROM table1 t1 INNER JOIN table2 t2 ON table.xid = table2.id WHERE t1.user_id = 100 AND (t1.type != 'FOO' AND t2.name != 'BAR') So t1.type is type ENUM with about 10 different options, and t2.name is also type ENUM with 2 options. My expected results would look a little like: 1, FOO, YUM 2, BOO, BAR 3, BOO, YUM But instead, all I'm getting is: 3, BOO, YUM Because it's filtering out all records which has 'FOO' as the type, and 'BAR' as the name. I keep waiting for that D'oh! moment where it hits me and I feel like an idiot for not realizing what I'm doing wrong. But it hasn't come. And I still feel like an idiot, lol. I appreciate any light any of you can shed on this! Many thanks in advance for the help!

    Read the article

  • SQL SERVER FOR XML SYNTAX

    - by Raj73
    How can I get an output as follows using FOR XML / sql query. I am not sure how I can get the Column Values as Elements instead of the tables' column Names. I am using sql server 2005 I HAVE TABLE SCEMA AS FOLLOWS CREATE TABLE PARENT ( PID INT, PNAME VARCHAR(20) ) CREATE TABLE CHILD ( PID INT, CID INT, CNAME VARCHAR(20) ) CREATE TABLE CHILDVALUE ( CID INT, CVALUE VARCHAR(20) ) INSERT INTO PARENT VALUES (1, 'SALES1') INSERT INTO PARENT VALUES (2, 'SALES2') INSERT INTO CHILD VALUES (1, 1, 'FOR01') INSERT INTO CHILD VALUES (1, 2, 'FOR02') INSERT INTO CHILD VALUES (2, 3, 'FOR03') INSERT INTO CHILD VALUES (2, 4, 'FOR04') INSERT INTO CHILDVALUE VALUES (1, '250000') INSERT INTO CHILDVALUE VALUES (2, '400000') INSERT INTO CHILDVALUE VALUES (3, '500000') INSERT INTO CHILDVALUE VALUES (4, '800000') The Output I am looking for is as follows <SALE1> <FOR01>250000</FOR01> <FOR02>400000</FOR02> </SALE1> <SALE2> <FOR03>500000</FOR03> <FOR04>800000</FOR04> </SALE2>

    Read the article

  • SQL: How to Return One DB Row from Two That Have The Same Values In Opposite Columns Using the MAX F

    - by OneSource
    Hi, This is what I'm trying to do. I have three columns in a table - ID, Column1, Column2 - with this example data: ID Column1 Column2 1     1            2 2     2            1 3     4            3 4     3            4 Since, in the first two rows, Column1 and Column2 have the same values (but in different columns), I want my MAX query to return an ID of 2. Same thing with rows 3 and 4 .... since Columns 1 and 2 have the same values (but in different columns), I want MAX(ID) to return 4. Of course, with MAX, you use Group By, but that will not work in my case. In effect, I need a Group By to work across two columns. Is this possible? If not, what's the best way to accomplish getting the IDs of 2 and 4 given the matching values that are in different columns? Thanks!

    Read the article

  • How can get unique values from data table using dql?

    - by piemesons
    I am having a table in which there is a column in which various values are stored.i want to retrieve unique values from that table using dql. Doctrine_Query::create() ->select('rec.school') ->from('Records rec') ->where("rec.city='$city' ") ->execute(); Now i want only unique values. Can anybody tell me how to do that... Edit Table Structure: CREATE TABLE IF NOT EXISTS `records` ( `id` int(11) NOT NULL AUTO_INCREMENT, `state` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `school` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=16334 ; This is the Query I am using: Doctrine_Query::create() ->select('DISTINCT rec.city') ->from('Records rec') ->where("rec.state = '$state'") // ->getSql(); ->execute(); Generting Sql for this gives me: SELECT DISTINCT r.id AS r__id, r.city AS r__city FROM records r WHERE r.state = 'AR' Now check the sql generated:::: DISTINCT is on 'id' column where as i want Distinct on city column. Anybody know how to fix this. EDIT2 Id is unique cause its an auto incremental value.Ya i have some real duplicates in city column like: Delhi and Delhi. Right.. Now when i am trying to fetch data from it, I am getting Delhi two times. How can i make query like this: select DISTINCT rec.city where state="xyz"; Cause this will give me the proper output. EDIT3: Anybody who can tell me how to figure out this query..???

    Read the article

  • Prolog Beginner: How to make unique values for each Variable in a predicate.

    - by sixtyfootersdude
    I have a prolog predicate: DoStuff( [A|B] ) :- <Stuff that I do> ... </Stuff that I do> It is all done except it needs to do return unique values. Ie if you do: ?- DoStuff(A,B,C,D). it should return: A=1; B=2; C=3; D=4. (Or something similar, the key point is that all of the values are unique). However you should be able to do this too: ?- DoStuff(A,A,B,B). And still get a valid answer. Ie: A=1; B=2. How can I do this? What I was planning on doing was something like this: DoStuff( [A|B] ) :- <Stuff that I do> ... </Stuff that I do> unique([A|B]). unique([]). unique([A|B]) :- A is not B. However I think that will make DoStuff([A,A,B]) not work because not all values will be unique.

    Read the article

  • Converting rows to Columns in SQL

    - by Ram
    I have a table (actually a view, but simplified my example to a table) which gives me some data like this id CompanyName website 1 Google google.com 2 Google google.net 3 Google google.org 4 Google google.in 5 Google google.de 6 Microsoft Microsoft.com 7 Microsoft live.com 8 Microsoft bing.com 9 Microsoft hotmail.com I am looking to convert it to get a result like this CompanyName website1 website2 website3 website 4 website5 website6 ----------- ------------- ---------- ---------- ----------- --------- -------- Google google.com google.net google.org google.in google.de NULL Microsoft Microsoft.com live.com bing.com hotmail.com NULL NULL I have looked into pivot but looks like the record(row values) cannot be dynamic (i.e can only be certain predefined values). Also, if there are more than 6 websites, I want to limit it to the first 6 Dynamic pivot makes sense, but I would have to incorporate it into my view ?? Is there a simpler solution for this ? Here are the SQL scripts CREATE TABLE [dbo].[Company]( [id] [int] NULL, [CompanyName] [varchar](50) NULL, [website] [varchar](50) NULL ) ON [PRIMARY] GO insert into company values (1,'Google','google.com') insert into company values (2,'Google','google.net') insert into company values (3,'Google','google.org') insert into company values (4,'Google','google.in') insert into company values (5,'Google','google.de') insert into company values (6,'Microsoft','Microsoft.com') insert into company values (7,'Microsoft','live.com') insert into company values (8,'Microsoft','bing.com') insert into company values (9,'Microsoft','hotmail.com')

    Read the article

  • How create new array which subtracts values from 2 double arrays in C#?

    - by Tomek eM
    Helou it's my problem, I have 2 array which have double values: (this is function which get back values(latitude) from richTextBox) private Tuple<double>[] szerokosc(string[] lines) { return Array.ConvertAll(lines, line => { string[] elems = line.Split(','); double we = 0.01 * double.Parse(elems[3], EnglishCulture); int stopnie = (int)we; double minuty = ((we - stopnie) * 100) / 60; double szerokosc_dziesietna = stopnie + minuty; return new Tuple<double>(Math.Round(szerokosc_dziesietna, (int)numericUpDown2.Value)); }); ; } (this part of code call function) var data1 = szerokosc(szerdlugeo_diag_gps.Lines); var data2 = szerokosc(szerdlugeo_diag_gpsglonass.Lines); What should I do, to get something like this: for example: var data3 = data1 - data2; My values in this data looks like (f.e.) data1 = (x11, x12, ... x1(n) ): 53.11818160073043, 53.11816348903661, 53.11814874695463, ... data2 = (x21, x22, ... x(2n) ): 53.11814200771546, 53.118131477652156, 53.11812263239697, 53.11811884157276, 53.11811631435644, .... I would like back data3 = (x31=x11-x21, x32=x12=x22, ... x(3n)=x(1n)-x(2n) ) It would be good if it included the following condition: if data1 = ( 1, 5, 6, 8) data2 = (1.5, 3.3) data3 = (-0.5, 1.7) not data3 = (-0.5, 1.7, 6, 8) Please help.

    Read the article

< Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >