Relative Content

Tag Archive for sqlmysql

Get all tax rates within a given date range

I have a table with tax rates. Each tax rate has two date fields: ‘valid_from’ and ‘valid_to’. ‘valid_to’ can be NULL, then the tax rate is valid until a later tax rate is inserted. Now I want to determine all tax rates valid in a given period with :start_date and :end_date. The problem is that a tax rate without ‘valid_to’ is valid, viewed individually, as long as its valid_from is not after the given period. So I have to take into account whether such tax rates have been replaced by later tax rates. But it can also be the case that a tax rate with valid_to = NULL falls in part of the given period and then a new tax rate takes over the next part of the period.
My approach still has problems with this:

sql-Whether the database query is projected or joined first?

For the following sql query statements: Select Distinct sno, sname From Student, SC Where Student.sno=SC.sno And cno=’C001′ Please use common sense to determine which of the following query plans should be executed most efficiently? (Assuming the SC has a citation on the cno and the Student has an index on the snoo) ()

sql-Whether the database query is projected or joined first?

For the following sql query statements: Select Distinct sno, sname From Student, SC Where Student.sno=SC.sno And cno=’C001′ Please use common sense to determine which of the following query plans should be executed most efficiently? (Assuming the SC has a citation on the cno and the Student has an index on the snoo) ()

Cascading rolling total logic in SQL

I am trying to recreate the cascading sum logic of our Student Information System (SIS) to build a tracking report that will aggregate all graduation requirements in one place.

Wrong comparing double column to string in MySQL [duplicate]

This question already has answers here: mysql query compare string with int value (3 answers) Closed 17 days ago. SELECT t.id, t.status, t.charges FROM parcel AS t WHERE t.user_id = 1 AND t.status = ‘delivered’ AND t.charges = ‘some string’ ORDER BY t.id DESC i have this mysql query. it returns some result, but it […]