Viewing 15 posts - 286 through 300 (of 1,468 total)
SQL is not Excel. By default, it cannot see the value in the previous or next row.
However, Window Functions are going to be your new best friend for this task,...
January 19, 2021 at 8:47 am
Deadlocks are not my strong point. That said, deadlocks occur when 2 or more processes are waiting on each other to access the same resource. The deadlocks can occur at...
January 19, 2021 at 8:40 am
This may be what you are looking for .
SELECT *
FROM COMPANY
WHERE PRODUCTS IN ( 'Product1', 'Product2', 'Product3', 'Product4' );
January 15, 2021 at 5:33 am
If you are only interested in specific employees, then put the filter on the Employee table
WITH cteHours AS (
...
)
SELECT e.identifier
, AllHours = ISNULL(SUM(h.[HOURS]),0)/60.00
FROM cms.dbo.Employee AS e
LEFT JOIN...
January 13, 2021 at 12:28 pm
I cannot see your tables or the data in them, so I cannot test the scripts.
The query that you have is not the same as the one that I posted. ...
January 13, 2021 at 10:00 am
@DesNorton - yes it works now but if the employee ID is there and he or she don't swipe then nothing is captured as it would appear as null....
January 13, 2021 at 7:52 am
If you have an unknown list of [Type], dynamic cross-tab queries are dealt with expertly and in great detail in these two Jeff Moden articles:
https://www.sqlservercentral.com/articles/cross-tabs-and-pivots-part-2-dynamic-cross-tabs
January 13, 2021 at 7:01 am
There is no need for the sub-query
SELECT sc.ID
, sc.[Name]
...
January 13, 2021 at 6:55 am
January 7, 2021 at 7:23 am
I don't like these massive procs with code branches. I would create a separate proc for each bucket. Then in this proc, EXEC the relevant new proc within each IF...
January 6, 2021 at 4:05 pm
What you need is a PIVOT or a Cross-Tab. The following SQL will work for your provided sample data
SELECT m.zplid
...
January 6, 2021 at 6:17 am
Hi Des
thanks for the answer it works well except for values which are zero then it doesn’t list them. how to list the zero values?
For example if I include...
January 5, 2021 at 2:36 pm
Why are you using a cursor? A simple sum with group by will do the trick
WITH cteHours AS (
SELECT emp_id
...
January 5, 2021 at 9:23 am
Just a thought ...
What about an exclusion table (or set of tables) that you can populate per customer. Then modify your queries to exclude data based on the config table.
As...
December 24, 2020 at 8:20 pm
Thanks for the suggestions. I am still curious to know why the MERGE statement deadlocks though. Any ideas?
Here is a page with a long list of known issues with...
November 17, 2020 at 9:52 am
Viewing 15 posts - 286 through 300 (of 1,468 total)