copy all records with 2 equals data from table1 to one record in table2 (second part)
hi, 
i have an other problem, i would like obtaining for each user the time trend of an analysis. 
i mean, considering table 
  
table1 
accessdate\_\_usercode\_\_analisisname\_\_\_\_analisisresult 2012-01-01\_\_\_\_1\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_10  2012-01-01\_\_\_\_1\_\_\_\_\_\_\_\_\_\_\_\_a2\_\_\_\_\_\_\_\_\_\_\_\_\_\_15  2012-01-01\_\_\_\_1\_\_\_\_\_\_\_\_\_\_\_\_a3\_\_\_\_\_\_\_\_\_\_\_\_\_\_12  2014-03-01\_\_\_\_1\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_12  2014-03-01\_\_\_\_1\_\_\_\_\_\_\_\_\_\_\_\_a3\_\_\_\_\_\_\_\_\_\_\_\_\_\_13  2012-01-01\_\_\_\_2\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_14  2012-01-01\_\_\_\_2\_\_\_\_\_\_\_\_\_\_\_\_a2\_\_\_\_\_\_\_\_\_\_\_\_\_\_15  2012-01-01\_\_\_\_2\_\_\_\_\_\_\_\_\_\_\_\_a3\_\_\_\_\_\_\_\_\_\_\_\_\_\_20  2013-03-01\_\_\_\_2\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_3  2012-01-01\_\_\_\_3\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_2  2012-01-01\_\_\_\_3\_\_\_\_\_\_\_\_\_\_\_\_a2\_\_\_\_\_\_\_\_\_\_\_\_\_\_1  2014-01-01\_\_\_\_3\_\_\_\_\_\_\_\_\_\_\_\_a1\_\_\_\_\_\_\_\_\_\_\_\_\_\_10 
  
i would like obtaining a table like this, which contains the analysis a1 time trend for each user: 
  
table 2 
user\_\_\_\_\_analysis.number\_\_date.a1.1\_\_\_\_\_a1.1\_\_\_\_\_date.a1.2\_\_\_\_\_a1.2\_\_\_\_\_date.a1.3\_\_\_\_\_a1.3\_\_\_\_\_date.a1.4\_\_\_\_\_a1.4 
1\_\_\_\_\_\_\_\_\_\_\_\_\_2\_\_\_\_\_\_\_\_\_2012-01-01\_\_\_\_\_\_\_10\_\_\_\_\_\_2012-01-01\_\_\_\_\_12\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ 
2\_\_\_\_\_\_\_\_\_\_\_\_\_2\_\_\_\_\_\_\_\_\_2012-01-01\_\_\_\_\_\_14\_\_\_\_\_\_2013-03-01\_\_\_\_\_\_3\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ 
3\_\_\_\_\_\_\_\_\_\_\_\_\_2\_\_\_\_\_\_\_\_\_2012-01-01\_\_\_\_\_\_\_2\_\_\_\_\_\_2014-01-01\_\_\_\_\_10\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ 
  
  
table 2 should contain 50 column. 
i would like obtaining this table format in order to select users with a particular analysis time trend. 
for instance users which have a1 time trend like this: five times over 10 in 5 consecutive analysis. 
  
do you think that table2 is useful to obtain this trend. 
do you think it is possible performing it with a sql query or i must use also php ? 
  
thank a lot 
best regards 
paolo
i was using @n to count the records in each group but realized that i could do that without the @n 
  
however i have now put it back as an incrementing group identifier so i am not relying on the dates. this should cure the "six-in-one-day" problem 

select 
 user
 , count(*) as `count`
 , group\_concat(datarichiesta,' (',result,')' order by datarichiesta separator ' , ') as dates
from
 (
 select 
 datarichiesta
 , @n := if((codicepz<>@prevuser) or (@prevres < 10) or (risultato < 10)
 or (datarichiesta > @startdate + interval 6 month)
 , @n+1, @n) as groupno
 , @startdate := if((codicepz<>@prevuser) or (@prevres < 10) or (risultato < 10)
 or (datarichiesta > @startdate + interval 6 month)
 , datarichiesta, @startdate) as startdate
 , @prevres:=risultato as result
 , @prevuser:=codicepz as user
 from mastertot
 join (
 select @n:=0, @prevres:=null, @prevuser:=null
 ) as init
 where descrprestaz = 'a1'
 order by codicepz, datarichiesta
 ) as detail
group by user,groupno
having `count` >= 5;
Hi,  

  

check the following Code  

SQLCopy Code

```
-- Question 1 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E

-- Question 1&2 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites',
CASE WHEN (E.TotalTime/60)>=6 THEN E.TotalTime - (30* ROUND((E.TotalTime/60*6),1))
     ELSE (E.TotalTime/60) END 'TotalWorkHours'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E
```
  

  

For ur Question 2, I am not getting. give some more details about that. if possible send some sample data. if access over lap like (From date is 2013 -04-05 11:55:00PM to 2013-04-05 19:10:00PM)  

then we can't able to fine the time difference. So check the code for Question No 1 and give the feedback.  

  

Regards,  

GVPrabu Hi, Really hard to work this out from your query but I suspect the answer would be a correlated sub query to find the latest appointment date.



https://www.geeksforgeeks.org/sql-correlated-subqueries/ You need to iterate over the resource...

 
```
while ($row = mysql_fetch_object($tariff_query)) {
    echo $row->somefield;
    echo $row->someotherfield;
}

```
 So you now get all the records not just the first one.

 BTW, if you want to use an object, why not use PDO or mysqli? mysql is dead - or as good as. [@najoua.abbaci](/u/najoua.abbaci)

mabye the flow can be adopted to following:

assign:

leftside: drresult (datatype: datarow)

right side:

dt\_datepv.asenumerable.orderby(function ( r ) datetime.parseexact(r(0).tostring.trim, “dd.mm.yyyy”, system.globalization.cultureinfo.currentuiculture.datetimeformat)).last()

so… you might be able to use synchronize. if you have more than 2 tables, you will need to use it multiple times. you would need something like this then pull a list of people in that database after the ammount of time 
 /**
 * @event discordmessagereaction
 */
 $.bind('discordmessagereaction', function (event) {
 var reactionevent = event.getevent(),
 reactionuser = reactioneve… let table = base.gettable("table 1")

let record = await input.recordasync("record", table)

await table.updaterecordasync(record.id, {

"single select": null

}) hi paul,

i believe the financial reporting covers in quite a lot of detail exactly what you are looking for.

from what i can tell you aren’t using templates in your tables…

[[image]](https://forum.enterprisedna.co/uploads/db7134/original/2x/5/559a333f85c159c8d9bec9235ca5c45997d08858.png "image")

if you want to get a certain order and custom table then you really need to use the template approach covered in t… Try this:  


```
UPDATE table1
SET
    table1.firstname = table2.firstname,
    table1.lastname = table2.lastname,
    table1.email = table2.email
FROM
    table1 JOIN table2
ON
    table1.userid=table2.userid
``` Here is a link to assist you.


<https://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx>


If you had done a web search with the question you entered here, you would have found multiple sites that give you the instructions