DB-Fiddle Expected Results: I want go get the number of the weekday for each date in the table dates. Therefore, I tried to go with the solution from this question but could not make it work: How do I need to modify the query to get the expected result? Answer Get rid of the date keyword it is only needed
Tag: sql
Email address lookup in SQL Server
We have a large subscriber database and have a lookup based on email address of type nvarchar(100). It sometimes times out probably because of a large scan of it. I want to improve this, but weary of some of the options. Would an index on it be ok, I can handle the additional storage if needed, or a computed …
SQL subtracting 2 subqueries
Fairly new to SQL and I wanted to see if I could get some help with subtraction. I want to subtract studentstaken – studentsnotreviewed and then as assign the alias total to the operation. I was thinking something along the lines of But getting some syntax problems I’m not too sure about. [Sample …
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…
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 –
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…