Calculate the remainder at each outlet by 04/15/01 for the database with accounts for not more than once a day. Result set: point, remainder.
Solution 2.3.1
Console
SELECT i.point, CASE inc
WHEN NULL
THEN 0
ELSE inc
END -
CASE out
WHEN NULL
THEN 0
ELSE out
END
FROM ( SELECT point, SUM ( inc) inc
FROM Income_o
WHERE '20010415' > date
GROUP BY point
) AS I FULL JOIN
( SELECT point, SUM ( out) out
FROM Outcome_o
WHERE '20010415' > date
GROUP BY point
) AS III ON III.point = I.point;
This problem is very similar to the previous problem 59 . In fact, there is additionally only date selection. In this regard, we want to draw attention to its representation in the query. The predicate compares the string with a field of datetime type. In A database management system (DBMS) by Microsoft Corporation. SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server there is a function CONVERT , which allows you to convert a string representation of date/time to this type, using different date formats. However, the string representation in the form of year month day, which is used in the present decision, will always be correctly converted implicitly to datetime , regardless of server settings [5 ].
Those we also managed to mistake in the previous problem, for sure, see here an attempt to correct it. Unfortunately, the attempt failed, that, on the other hand, gives you the chance to test self once again.
T&S
To solve the problem on SQL-EX.RU