Answer the question
In order to leave comments, you need to log in
Why did git pull start saving files as root?
On the server I do: git clone [email protected]:app.git
and I drag out the project, but then when I do git pull
all the files that have been changed or created become root, and during the first operation they were created on behalf of an ordinary ubuntu linux user.
Answer the question
In order to leave comments, you need to log in
Didn't check:
select
c.count_id,
t.balance
from counts c
left join
(
select o.operation_count_id, o.balance
from operation o
where o.date_count = (select max(date_count)
from operation
where operation_count_id = o.operation_count_id)
) t on t.operation_count_id = c.count_id
There is another option. Make 2 requests. In the first - in a temporary table to save the result of a query like
And with the second query, make your select but join this temporary table, and not the entire table of operations.
-- Создали таблицы
CREATE TABLE counts (count_id INT IDENTITY (1,1) , count_name nVARCHAR(20))
CREATE TABLE operation (operation_id INT IDENTITY (1,1) ,operation_count_id INT, balance MONEY,operation_date DATETIME ,operation_name NVARCHAR(50))
go
-- Очищаем таблицы
TRUNCATE TABLE counts
TRUNCATE TABLE operation
-- Заполняем данным
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Первый счет')
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Второй счет')
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Третий счет')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'10.3','01-01-2015','Первая операция по первому счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'25.5','02-02-2015','Вторая операция по первому счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'34.4','03-03-2015','Третья операция по первому счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(2,'11.7','01-01-2015','Первая операция по Второму счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(2,'22.2','04-04-2015','Вторая операция по Второму счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(3,'33.1','01-01-2015','Первая операция по Тертья счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(3,'33.7','02-02-2015','Вторая операция по Третья счету')
-- Запрос возвращает баланс последней операции по каждому счету
SELECT c.count_id,c.count_name
,o2.balance
,o2.operation_name
FROM counts c
JOIN (
SELECT operation_count_id,
MAX(operation_date) AS 'Max Date'
FROM dbo.operation
GROUP BY operation_count_id
) o ON o.operation_count_id=c.count_id
JOIN dbo.operation o2 ON o2.operation_count_id=o.operation_count_id AND o2.operation_date=o.[Max Date]
SELECT * FROM counts c LEFT JOIN operation o ON (c.count_id=operation_count_id) order by operation_time desc limit 1
like so.
SELECT *
FROM counts AS c
LEFT JOIN operation AS o ON (c.count_id=(
SELECT operation_count_id
FROM operation
ORDER by date
LIMIT 1) o
)
SELECT *
FROM counts AS c
LEFT JOIN operation AS o ON (c.count_id=(
SELECT MAX(operation_count_id)
FROM operation) o
)
Turn your eyes to hooks, they can be executed on behalf of the root.
*you can add a line chown user:group /way2project/* -R
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question