I have data in two tables with dates PAL date and HUB date. I’m looking to show the number of day difference in a table with 6 columns: Client 1day 2days 3days 4days 5days Client will display the clients grouped, 1 Day will display the count of how many datediff of 1. 2 Days will display the count of ho…
How can I optimize/modify this SQL query to have the same results but with better performance?
This SQL query takes time to execute and I don’t know how can I optimize it/or modify it to have the same results with better performance Answer I rewrote my query like this and it’s very fast Correct me, if I am wrong
how to combine queries from one table?
I have a table with dates and some data. How can I display data for each month (January, February, March), and also display the amount for three months, the average for three months and the maximum payment in one request? the result should be like this users date pay balance avg(balance) avg(pay) sum(pay) use…
I want sql query to change membership status
My site has users with user_id and Customer_id. Default membership status is pending. I want a query to change membership status to active by checking details in the other 2 tables. If users have …
Conversion failed when converting the varchar value of string to data type int
I got issue with my SQL as below statement. After execute it, got error : Conversion failed when converting the varchar value ‘ONWARDS’ to data type int. SELECT description, moreThanDay, CONCAT(…
Convert short month names into number
I have dates like this and I want to convert those short month names into numbers. Sep 30 2021 19:00:04 +08 My desired output is either one of them. 2021/30/09 19:00:04 or 20213009190004
How to solve this invalid select list?
Can anyone have any suggestions on what I’m missing on my query. I’m having error: Msg 8120, Level 16, State 1, Line 6 Column ‘Cars.dbo.tblTranslateTable.IDEvent’ is invalid in the select list …
How to use TO_DATE to update a DATE field in SQL to a PM time
What I need to do is pretty simple. I just need to update a DATE field in SQL to a PM time. Only thing is, if I use the TO_DATE function to update to an AM time, no problem… However if I try to do the same thing to set to a PM time using military time… It says that
Reset ROW_NUMBER() when previous partition ID changes
I am trying to reset the ROW_NUMBER() value when there is a change in one of the IDs when sequenced in datetime order. For example in the table below, when Location_ID changes, I want to reset the RowNum to 1. Here’s the statement I am using. I get RowNumX, but want RowNumY. EventDate Scan_Timestamp Ass…
Combine cells in access separated by comma
I am new to access and coding. I have a sheet comprising of huge data. I want some specified data in Access by running a query or VBA. What I want is to combine the data based on a column and each data separated by a comma. I am pasting the example of the sheet below: Input sheet Output data