I have a list of numbers in a database,one number per column,seven numbers per row. I want to be able to add up how many numbers match from the row below in each row as in my example. 43 18 33 12 48 22 25 17 43 6 29 11 1 8 =1 34 35 49 6 2 21 46 =2 41 30 48 38 45 35 46 =1 30 23 47 26 39 2 31 =3 15 24 20 47 2 31 29 31 43 25 18 29 3 23 38 26 27 13 43 41 35 =1 39 42 40 32 26 25 41 Another query question if I may: I have 2 fields Day of week , Weather How do I do a query such as: when did it last rain ? How many times was it cloudy ? Monday sunny Tuesday cloudy Wednesday cloudy Thursday overcast Friday rain Saurday cloudy Sunday sunny
Maybe it's just me, but can you explain this better?!? Thanks! (I suppose day_of_week is a date field) SELECT day_of_week FROM weathers_table WHERE weather = 'rain' ORDER BY day_of_week DESC LIMIT 0,1 Code (markup): (I suppose you have one record per day) SELECT COUNT(*) FROM weather_table WHERE weather = 'cloudy' GROUP BY weather Code (markup): HTH, cheers!
Sorry guys Its my fault, I am not the best at trying to explain this stuff. I have a list of 6 temperature numbers in a row each day. The following day I have another 6 numbers. I want to query the database to see how many of the 6 numbers were the same as the day before.
Uhm... I think your DB is not designed very well, you should have one row for each temperature for each day (not 6 temperatures in a record) Otherwise it's quite a PITA to do what you ask for - at least for me, and using SQL only...
Hi If you dont have any problem , it will be easier to understand and help if you post the table structure here. Just a qustion 6 numbers in a row means are they all on separate fields or in the same fields?
Thanks Kashem,yes they are in 6 seperate fields. Each row is id date day then the 6 temperature fields (9 fields in total).