Skip to content

Tag: sql

How can I delete record based on date?

I have a set of data with DateTime type in SQL. I want to delete whatever data belong to a specific date for ex: 2021-11-02 21:07:52.663. if I have value like above I want to delete records using just date. 2021-11-02. Answer This will compare the date part of your datetime to the desired date:

Use having on SQL Query

I’m use the next query to get the average of memory used, but only need get data when average is more than x value And show me the next error Found 1 problemnline 1:152: Cannot use HAVING filter on non-aggregate [@timestamp]; use WHERE instead” And when use WHERE clause, like this Show the next er…

Query to sum the top “n” records

I would like to sum the forecast qty column for only the first “n” date records. For example for each item number the earliest(or first) three date records Current Query: Table Desired Result Answer Assign a row number to each record, partitioning by Item (this will start a new row counter for eac…