-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 10 4680 6621 30812
C/C++ Header 3 99 286 496
-------------------------------------------------------------------------------
SUM: 13 4779 6907 31308
-------------------------------------------------------------------------------
tmdb_id = values(tmdb_id),
type = values(type)
+----+------+--------+------+---------------------+
| id | line | status | user | startDate |
+----+------+--------+------+---------------------+
| 1 | TEST | star | NULL | 2015-04-29 12:54:30 |
| 2 | TEST | stop | NULL | 2015-04-29 12:54:59 |
| 3 | FOO | stop | NULL | 2015-04-29 13:07:29 |
| 4 | FOO | star | NULL | 2015-04-29 12:55:21 |
+----+------+--------+------+---------------------+
select id, if(@line=line AND @status!=status,@startDate, NULL) as endDate,
@line:=line as line, @status:=status as status, @startDate:=startDate as startDate
FROM (select id, line,status, startDate from linestatuslog order by line, status, startDate) as c;
+----+---------------------+------+--------+---------------------+
| id | endDate | line | status | startDate |
+----+---------------------+------+--------+---------------------+
| 4 | NULL | FOO | star | 2015-04-29 12:55:21 |
| 3 | 2015-04-29 12:55:21 | FOO | stop | 2015-04-29 13:07:29 |
| 1 | NULL | TEST | star | 2015-04-29 12:54:30 |
| 2 | 2015-04-29 12:54:30 | TEST | stop | 2015-04-29 12:54:59 |
+----+---------------------+------+--------+---------------------+
mysql> SELECT AUTO_INCREMENT FROM information_schema.tables where table_schema = DATABASE() and table_name = 'test3';
+----------------+
| AUTO_INCREMENT |
+----------------+
| 16 |
+----------------+
1 row in set (0.00 sec)
mysql> insert ignore into test3(name) VALUES ('xxx'),('aaa'),('fff');
Query OK, 0 rows affected (0.00 sec)
Records: 3 Duplicates: 3 Warnings: 0
mysql> SELECT AUTO_INCREMENT FROM information_schema.tables where table_schema = DATABASE() and table_name = 'test3';
+----------------+
| AUTO_INCREMENT |
+----------------+
| 19 |
+----------------+
select item,
SUM(IF(price_id = 'price1', price, 0)) as price1,
SUM(IF(price_id = 'price2', price, 0)) as price2
FROM pivot_sample GROUP BY item;
SET @rank=0;
SET @current_field=0;
select a.field_a, a.field_b,
@rank:=if(@current_field = a.field_a,@rank+1,0) as rank,
@current_field:=a.field_a as current
FROM (select field_a, field_b from test2 where field_a IN (1,2)
ORDER BY field_a, field_b DESC ) as a having rank < 3;
SELECT c.name, b.name, count(*) from unslugi as a
left join info as b on a.job_id=b.id
left join info as c on a.worker_id=c.id
WHERE a.usluga_okazana=1
GROUP BY a.job_id, a.worker_id;