Viewing 15 posts - 916 through 930 (of 1,391 total)
This uses the daterange function described here:
https://www.sqlservercentral.com/scripts/a-daterange-table-valued-function
(the actual daterange code used is closest to this one)
drop table if exists dbo.TestUserAccount;
go
create table dbo.TestUserAccount(
AccountName varchar(20) primary...
August 5, 2020 at 12:08 pm
;with
details_summary_cte(Manage_GUID, details_row_count) as (
select Manage_GUID,
count(*) /* ... other aggregate functions */
...
July 31, 2020 at 2:35 pm
You could successively cross apply
declare
@price int=100;
;with some_discounts_cte(first_pct, second_pct, third_pct) as (
select 20.0, 20.0, 50.0)
select
...
July 30, 2020 at 9:24 pm
drop table if exists #rev;
go
create table #rev(
RevisionId int,
AssemblySiteId int,
Status nvarchar(200));
go
insert into #rev(RevisionId,AssemblySiteId)
values
(1900,200),
(2000,300),
(5000,800);
drop table if exists #location;
go
create table #location(
locRevisionId int,
...
July 30, 2020 at 5:43 pm
Maybe the short answer is to uncomment out the line:
--SR.DBLSTOCKONHAND as SOH
and uncomment out the FROM clause and change it to:
--left join STORERNG as...
July 30, 2020 at 1:14 pm
from DAILYSALES DS
left join DISCHDR as DH on DS.INTOFFERCODE=DH.CTRCODE
...
July 29, 2020 at 12:39 pm
drop table if exists dbo.#TestDates;
go
create table dbo.#TestDates(
yr int not null,
mo ...
July 28, 2020 at 12:31 pm
An alternative to creating a TargetDate column would be to create a Priorities table which contains columns related to the priority. Then calculate the TargetDate when you need it. Priorities...
July 27, 2020 at 4:47 pm
drop table if exists dbo.TestBatch;
go
create table dbo.TestBatch(
[BatchNum] [nvarchar](10) NULL,
[ItemName] [nvarchar](50) NULL,
[DocDate] [date] NULL,
[WhsCode] [nvarchar](10) NULL,
[Qty] [decimal](18, 0)...
July 27, 2020 at 4:21 pm
Thank for the many replies....the idea is show the first row of others. The point is that I need to "call" same columns just to apply a filter into...
July 27, 2020 at 3:49 pm
Hmmm... that's odd. Maybe we're both right until the OP clarifies?!?
When the OP first posted: Input
SELECT 10,'03/22/2020','12/31/9999'
Output:
10 '03/22/2020' '03/31/2020'
10 '04/01/2020' '12/31/9999'
Then the second post breaks down the same data differently...
July 26, 2020 at 3:48 am
Aaah that was true before I borrowed the charindex section of Phil's code.
drop function if exists dbo.fnTIDprefix_Expand;
go
create function dbo.fnTIDprefix_Expand(
@TIDprefix ...
July 25, 2020 at 9:42 pm
Jason A. Long the "s3 string" characters which appear after the brackets do not appear in any of the OP's example rows. Imo that's a made up requirement which most...
July 25, 2020 at 7:03 pm
When I switch the datediff metric to nanoseconds and run the script over and over again the tally and cte are equal at 0 ns up to about 500 rows. ...
July 25, 2020 at 2:08 pm
This script prints start/stop timestamps before/after running 2 queries. Query 1 counts rows generated by the tally function. Query 2 uses a recursive CTE. With n=10000, Q1 takes 0 ms. ...
July 25, 2020 at 12:20 pm
Viewing 15 posts - 916 through 930 (of 1,391 total)