I have a database table as below. Id 1 and 4 are old members and their data is updated (as seen in updated date column). Id 2 and 3 new members. So now how we can query in SQL Server and get list of …
spool to .csv file using for loop
need to spool output into .csv file using loop, fyi…I have data in 4 diff partition. but no sure how to proceed. code be like. result:- not sure if I am spooling properly, also please check the index variable of for loop in used correctly in my select statement. Answer You don’t need 4 different q…
How to SELECT records from a temp table applying a specific condition?
I have dumped a file into a temp table and trying to pull records where the score is <= 100. The column has values for example, 3, 4.50, 10.02, 99.88,99,99, 100, 100.2, 100, 116, 116.44 etc. I need …
Best practice to keep track of timestamps? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question If have been trying to keep track of multiple timestamps regarding user-related inputs and my …
SQL Distinct on One Column with NO ID
I have a problem where I need to select three columns from a table in Access to populate another table but it needs to be distinct on one column ONLY. I tried the GROUP BY as follows But when I use above with a SELECT INTO and check for duplicates there are some. I have looking at this post –
Break out nested data within SQL, criteria across multiple rows (similar to dcast in R)
I’m trying to write a simple query to take a data set that looks like this: ID | Col2 X B X C Y B Y D and return this: ID | Col2 | Col3 X B …
Get row Sums across multiple users/tables
I am working in SQL Server, and I have three tables that I have simplified below USERS: POINTS: CLAIMS: I’m trying to run a report of distinct users with a sum of points earned and a sum of points used. I’ve started with the join of tables by userId… but of course that returns the user multi…
How to generate a Forecast based on last row result in SQL
I need help to develop the proposed task: I need to count the current month active employees and then generate a “forecast” for the next six months, the forecast is just the last total active from the current month over the next six months, just changing the date value on the result. Expected Resu…
How can I find the max “income” from every “product” in every “province”? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I have this table PRODUCT PROVINCE INCOME Apple Seville 13.2 Melon Almeria 3.6 … ……
Oracle SQL get last Sunday [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. Improve this question I am currently using the below statement to sucessfully get it Is there…