Tag sql

[Solved] SQL Database Algorithm

Even though this question is Way too broad, and actually not asking anything, i’ll give it a few minutes of attention. 1) You backup the current state and work on a Sandbox! 2) if your only need is few reports,…

[Solved] HOW TO SUBSTRING in SQL QUERY

Just check this sample , you have to use charindex(to find the index of comma) and substring function to get substring value Declare @var varchar(50) = ‘21699,21712’ select charindex( ‘,’, @var), substring ( @var, charindex(‘,’, @var)+1, len(@var)) you can also…

[Solved] Convert SQL into LINQ and Lambda

Maybe something like this: var result= ( from s in db.Stands join cp in db.ContractProducts on s.Id equals cp.StandId join p in db.Products on cp.ProductId equals p.Id where s.EventId == 1 group p by p.Description into g select new {…

[Solved] Slightly Complicated SQL query

Something like this should return the specified resultset: SELECT u.id AS user_id , u.user_name , SUM(a.user_id IS NOT NULL) AS total_count_of_articles FROM users u LEFT JOIN users_articles a ON a.user_id = u.id GROUP BY u.id, u.user_name ORDER BY total_count_of_articles DESC…