Skip to content

Tag: sql

query for first and last day of month

If I have the name of the month, how can I have the first and last day of that month in SQL? I have this query to returns the month names: Result: Now, how can i get the first and last day of that months? changing the query. Answer Try this :- Result :- Result obtained taking the help from

SQL BETWEEN for text vs numeric values

BETWEEN is used in a WHERE clause to select a range of data between two values. If I am correct whether the range’s endpoint are excluded or not is DBMS specific. What I can not understand in the following: If I have a table of values and I do the following query: The query returns as results rows inclu…

Find start and end dates when one field changes

I have this data in a table When ever the value in FIELD_D changes it forms a group and I need the min and max dates in that group. The query shoud return The examples that I have seen so far have the data in Field_D being unique. Here the data can repeat as shown, First it is “N” then

MySQL concatenation operator

I don’t know concatenation operator for MySQL. I have tried this code for concatenation: SELECT vend_name || ‘ (‘ || vend_country || ‘)’ FROM Vendors ORDER BY vend_name; But it didn’t work. Which …

How to sync two MySQL tables?

If I have a table (lets call it orders) on one server of mine, named, for example, local. And I have this same table one another server of mine, named, for example, remote. My problem is, what is the best way to sync these two tables? I would like a solution that replaces a registry if the local is different