Skip to content

Count total day difference in a Pivot SQL

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 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 …

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 …

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