Viewing 15 posts - 916 through 930 (of 1,398 total)
Ok ok I changed the decode to 'South Africa' and now it does work. Misdiagnosed due to misleading code? Yea, if it scans once and there's no dependency then it...
August 7, 2020 at 1:43 pm
Wait a sec. North Africa is in the code twice!
August 7, 2020 at 1:39 pm
The bottom grouping is the code with tally ordered by 1,2,3. The top is UNION ALL with same ordering
August 7, 2020 at 1:33 pm
When CROSS JOIN with the tally table the resulting ordering may not align with Region. It's not known which region will be 1 or 2 or ... unless joined back...
August 7, 2020 at 12:44 pm
When the code posted above runs it produces the following output:
CountryStatenamesurnameagegender
USAlabamaJohnDon45NULL
CanadaTorontoMarkBagwell35Male
This is exactly what was requested no? Is it a requirement the query be dynamic because the...
August 6, 2020 at 11:52 am
drop table if exists dbo.TestAZURE_JSON;
go
CREATE TABLE dbo.TestAZURE_JSON (
RowID int IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
Country varchar(10),
[State] varchar(10),
[JSON_Value] nvarchar(max));
go
INSERT dbo.TestAZURE_JSON(Country, [State], [JSON_Value]) VALUES
('US', 'Alabama', '{"name":"John","surname":"Don","age":45}'),
('Canada', 'Toronto', '{"name":"Mark","surname":"Bagwell","age":35,"gender":"Male"}');
select
...
August 5, 2020 at 7:13 pm
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
Viewing 15 posts - 916 through 930 (of 1,398 total)