Viewing 15 posts - 91 through 105 (of 7,550 total)
SELECT DISTINCT UPC, STARTDATE, [MASTERCHAINNAME], REPLENTYPE,
CASE WHEN [REPLENTYPE] IS NULL THEN 'Not in CKB'
WHEN [REPLENTYPE] = 'NONE' THEN 'Non Replenishable'
ELSE 'Replenishable' END AS 'Replentype'
FROM dbo.tablename t1
WHERE...
July 1, 2024 at 9:58 pm
Select TBL1.caseid, TBL1.anotherid, TBL2.locked
From atable1 AS TBL1
JOIN atable2 AS TBL2 ON atable2.caseid = atable1.caseid
where TBL1.date Between CAST('2021-03-19' as Date) and CAST('2023-03-30' as Date)
and not exists(select * from atable2 AS TBL2 ...
July 1, 2024 at 6:13 pm
You just need a NOT EXISTS in the original query, but can't be coded accurately without knowing which columns are in which table(s).
July 1, 2024 at 5:58 pm
That query can't run, because you didn't specify which "caseid" in the SELECT.
We have NO way to know which column(s) are in which tables. You need to alias EVERY column...
July 1, 2024 at 3:50 pm
Assuming that AVALUE is based on the ID value (that is, the same ID always has the same AVALUE), then you can leave AVALUE out of the GROUP BY. If...
June 28, 2024 at 5:50 pm
Or take advantage of SQL's inherent capabilities by using the sql_variant data type (yes, technically you don't need the second CAST):
SELECT DISTINCT
...
June 27, 2024 at 1:56 pm
The above general approach should work, there just may be a more efficient way that's not popping into my head right now.
June 21, 2024 at 8:44 pm
We could brute force it; I'll try to think of a better way when I get a chance:
;WITH cte_person AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY...
June 21, 2024 at 7:05 pm
Combining them wouldn't optimize it. For three different tables, SQL must still scan each table/covering index to provide the results.
June 19, 2024 at 7:34 pm
Realistically at this point, I'm just trying to gather a better understanding of what is going on here for my own sanity. If the Execution plan shows SQL expects...
June 19, 2024 at 5:32 pm
Personally, I'd try using a temp table and see if it works well before I spent lots of time trying other work-arounds:
declare @p3 dbo.IdList
select * into #p3 from @p3
create unique...
June 19, 2024 at 3:17 pm
I don't know Snowflake SQL, but based on Google for their syntax, derived tables are allowed in an UPDATE:
UPDATE target SET v = b.v /* actual UPDATE example from Snowflake...
June 17, 2024 at 5:37 pm
I think it's easier to use ROW_NUMBER(), like this:
;WITH cte_STUDENTIDPOOL AS (
SELECT STATESTUDENTID, ROW_NUMBER() OVER (ORDER BY STATESTUDENTID) AS row_num
...
June 17, 2024 at 1:50 pm
Yes, that is correct.
June 15, 2024 at 5:50 am
Roughly:
;WITH cte_person AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY hPerson ORDER BY hID) AS row_num,
ROW_NUMBER() OVER(PARTITION...
June 14, 2024 at 6:00 pm
Viewing 15 posts - 91 through 105 (of 7,550 total)