[Solved] what should i do to make this SQL query work? [closed]

[ad_1] I’m quite sure this query will work; meaning that it won’t return an error but I’m not certain if it will return correct result as what you intended: SELECT s.Name, SUM(p.Note=5)/COUNT(*) as Anteil FROM Studenten s JOIN pruefen p ON p.MatrNr = s.MatrNr GROUP BY s.Name ORDER BY Anteil DESC, s.Name ASC; If this … Read more

[Solved] ASP.NET MVC – Complex Queries [closed]

Introduction [ad_1] ASP.NET MVC is a powerful web development framework that allows developers to create dynamic, data-driven web applications. It is a great platform for creating complex queries that can be used to retrieve data from a database. In this article, we will discuss how to create complex queries in ASP.NET MVC and how to … Read more

[Solved] How to select date of last 5 days? [closed]

[ad_1] You can use a recursive CTE: with dates as ( select cast(getdate() as date) as dte union all select dateadd(day, -1, dte) from dates where datediff(day, dte, getdate()) <= 4 ) select * from dates order by dte desc; Obviously, you can reference any other date you want instead of getdate(). Your example suggests … Read more

[Solved] Merging tables in SQL Server

[ad_1] You need to use JOIN to join both tables. SELECT * FROM dbo.bac A INNER JOIN dbo.data B ON B.counter = A.counter this should do it, but you need to filter your records as needed. 0 [ad_2] solved Merging tables in SQL Server

[Solved] sql payment distribution

[ad_1] Extending the answer to this question: payment distrubution oracle sql query You can still use the SQL MODEL clause. In this version, you need separate calculations for each distinct account_num. You can achieve this using the PARTITION keyword of the SQL MODEL clause to partition by account_num. Like this (see SQL comments for step-by-step … Read more

[Solved] sql update (help me )

[ad_1] First, figure out which records need to be updated: select * from tbl_order o inner join tbl_group g on g.grp_id = o.grp_id inner join tbl_indicator i on i.grp_nbr = g.grp_nbr and i.sect_nbr = g.sect_nbr where g.indicat != i.indicat Now, modify the query to update those records with the correct grp_id. Notice that I’ve added … Read more

[Solved] php mysql car parking query [closed]

[ad_1] Your query is referencing return_date, which isn’t a column in the airport_car_parking table. As for the logic of the query, you want to make sure that the $departure_date isn’t between any row’s departure_date or arrival_date. I would recommend the following query – $chk_date_sql=”SELECT * FROM airport_car_parking WHERE ‘$departure_date’ BETWEEN departure_date AND arrival_date;”; And then … Read more

[Solved] MySQL Error Files [closed]

[ad_1] The user that runs the MySQL daemon doesn’t have permission to write to your database directory. If you’re using a standard installation with default settings, the following command should fix that (edited to add sudo based on your edited output: if you can run as root, leave off the sudo): sudo chown -R mysql:mysql … Read more

[Solved] PHP send email foreach user

[ad_1] Your code was missing some curly brackets ( {} ): include (“../dbconnect.php”); $sql=”SELECT c.endofmonthform, c.startofmonthform, c.email, c.id, c.formlevel, c.mastersite, c.opmanager, u.userEmail FROM `clients` as c LEFT JOIN `users` as u on c.opmanager = u.userName WHERE endofmonthform=”22/09/2016″”; //TODAYS DATE BACK HERE! $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $enddate = $row[‘endofmonthform’]; // End $startdate = $row[‘startofmonthform’]; // Start $email = … Read more

[Solved] SQL query with order by clause

[ad_1] ‘Transaction’ is a pair of take + return. It’s identity is computed from source data so OPERATORs could be grouped the way you need. The query may fail on data with unpaired OPERATORs. declare @tbl table ( OPERATOR int, PRODUCT varchar(50), [USER NAME] varchar(100), [TIME STAMP] datetime); insert into @tbl(OPERATOR, PRODUCT, [USER NAME], [TIME … Read more

[Solved] Need to sum the results of a query

[ad_1] Try this one – CREATE FUNCTION dbo.udf_getCountCallOnDate ( @DateFrom DATETIME , @DateTo DATETIME ) RETURNS INT AS BEGIN RETURN ( SELECT SUM(CallsTakenOnDate) FROM dbo.PhoneCalls WHERE DateOfWork BETWEEN @DateFrom AND @DateTo ) END SELECT DateOfWork = CONVERT(VARCHAR(10), t.DateOfWork, 111) , [Count] = SUM(t.CallsTakenOnDate) FROM dbo.PhoneCalls t WHERE DateOfWork BETWEEN @DateFrom AND @DateTo ORDER BY t.DateOfWork … Read more