row

MySQL query comparing values to previous rows' values

被刻印的时光 ゝ 提交于 2019-12-13 14:25:35
问题 I've been searching but have been unable to find a solution to this--I know it's do-able but I just don't have the ninja SQL skills I need (yet).... I'm looking for a solution to this issue: I have a 2 tables related to stock market data. The first is a simple list of stock symbols with an ID and stock ticker symbol (ID,SYMBOL). The second table contains historical price data for each of the stocks. (ID, DATE, OPEN, HIGH, LOW, CLOSE, VOLUME). I'm trying to figure out how to query for stocks

Subtract two rows' values within the same column using Mysql group by ID

无人久伴 提交于 2019-12-13 10:56:22
问题 I have a table as shown below. I want to do a partition and then subtract the values in the same column to get the difference. Since there is no partition or equivalent function available in MySQL, can anyone give me an idea of how to do it? I have worked out the partition but not the other part. SELECT ID,Date, @row_number:=CASE WHEN @ID=ID THEN @row_number+1 ELSE 1 END AS row_number, @ID:=ID AS ID,value FROM table1, (SELECT @row_number:=0,@ID:='') AS t ORDER BY id,Date; Input: ID Date Value

How to group rows with same value in sql? [closed]

寵の児 提交于 2019-12-13 10:53:55
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . How to group rows with same value in sql? data1 123 12/03/2009 124 15/09/2009 data2 333 02/09/2010 323 02/11/2010 673 02/09/2014 444 05/01/2010 回答1: Try this DECLARE @temp TABLE(col1 varchar(20),col2 int, col3 varchar(20)) insert into @temp values ('data1', 123 , '12/03/2009'),('data1', 124 , '15

MySQL : Select records with conditions that applies to multiple rows

谁都会走 提交于 2019-12-13 10:45:35
问题 I have a table: DETAILS -------------------------------------------------------- ID | PARENT_ID | DATA_KEY | DATA_VALUE ======================================================== 1 | 1 | Guitar | 4 -------------------------------------------------------- 2 | 1 | Radio | 2 -------------------------------------------------------- 3 | 1 | Tv | 2 -------------------------------------------------------- 4 | 1 | Drum Kit | 3 -------------------------------------------------------- 5 | 2 | Guitar | 4

Set datagrid row background color WPF - Loop [closed]

一个人想着一个人 提交于 2019-12-13 09:45:26
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have one Task which go throw DataGridRow and do some task. When he finish it set background color for that row. I added cancel button to stop task, and continue button to continue where it finished last time. All work perfect except changing background color for row. This is XAML code, i'm new to WPF so it's

Add a column to a data frame that index the number of occurrences in a group

本小妞迷上赌 提交于 2019-12-13 09:17:36
问题 Given data frame like this Unit Anything A 3.4 A1 2.2 A 6.9 A1 1.1 B 2 B 3 Sort by anything, group by unit, add an index Unit Anything Index A 3.4 1 A1 2.2 2 A 6.9 2 A1 1.1 1 B 2 1 B 3 2 I know df[order(df$Anything),] orders by Anything . But I can't get a count to work. I tried stuff like dt = data.table(df) dt[,count := .N, by = list(Unit)] 回答1: After reading the related topics, by trial and error, the following seems to work.... ref: Add a "rank" column to a data frame df <- read.table

Make sure matrix row took from text file are same length(python3) [duplicate]

时间秒杀一切 提交于 2019-12-13 09:05:10
问题 This question already has answers here : Making sure length of matrix row is all the same (python3) (2 answers) Closed 5 years ago . so I have this code to input a matrix from a text file: import os path = input('enter file path') there = os.path.exists(path) if there == False: print('Invalid path') menu() matrix = open(path).read() matrix = [item.split() for item in matrix.split('\n')] menu_matrix(matrix) except(ValueError,TypeError): print('Invalid character in text file') My question is

Delete duplicate entries in a given row

耗尽温柔 提交于 2019-12-13 08:26:56
问题 I want to delete the duplicates in each row, such that there should be no "holes" in the row. What I have is: Col A Col B Col C Col D Col E Col F Col G A B C D A B A J I K J I K I B A B J I K L up to 40k rows. Output required: Col A Col B Col C Col D Col E Col F Col G A B C D J I K B A J I K L 回答1: Make sure that the columns to the right of your source data are blank. The output is going to go there. Place this routine in a standard code module and run it: Public Sub CullDistinct() Dim rSrc

php count array rows with same id

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 07:59:00
问题 Hello everybody I have a script that loops an array that put data in a CSV file, i need to count the rows with same ID. this is my scritpt that loops the array and put it in a csv file for export. public function fputToFile($file, $allexportfields, $object, $ae) { if($allexportfields && $file && $object && $ae) { //one ready for export product $readyForExport = array(); //put in correct sort order foreach ($allexportfields as $value) { $object = $this->processDecimalSettings($object, $ae,

Best way to change order of rows in MySQL table?

99封情书 提交于 2019-12-13 07:36:45
问题 I have a MySQL table with rows that need to be sorted in a particular order decided by the user. In other words, need the user to be able to insert a new row at a random point in the table, and also move existing rows to a new random location/row number in the table output on a select query... Solutions I have thought of so far: I could use an integer with an ORDER BY, however, then i will need to update every row after the point of "insertion". I could use a timestamp and an index integer,