Viewing 15 posts - 1,231 through 1,245 (of 1,404 total)
WITH cteSports AS (
SELECT * ,sn = ROW_NUMBER() OVER (PARTITION BY name ORDER BY sport)
FROM #example
)
SELECT
cte.name
, cte.city
, cte.entryDate
, sport1 = MAX(CASE WHEN cte.sn =...
January 6, 2017 at 10:30 pm
When SQL processes a batch of records, it's an all or nothing process. If one of them has an error, all are aborted.
The only way to do skip a...
January 6, 2017 at 10:17 pm
Here are 3 different approaches that will acheive the same results
-- Using cte with ROW_NUMBER
WITH cte AS (
SELECT CustID, PrintedDate, rn = ROW_NUMBER() OVER (PARTITION BY CustID ORDER...
January 5, 2017 at 11:04 pm
Since your query does not have an ORDER BY clause, you are not guaranteed of any specific order.
Perhaps adding the following to the end of your query will help
ORDER BY...
January 5, 2017 at 10:51 pm
spectra (1/5/2017)
DesNorton (1/5/2017)
INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)
SELECT
@_id,
ROUND(CASE WHEN ta.const1 IS NULL OR ta.const1 != 0 THEN pd.COSTS_DST * ta.const1 / @const2
...
January 5, 2017 at 7:00 am
INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)
SELECT
@_id,
ROUND(CASE WHEN ta.const1 IS NULL OR ta.const1 != 0 THEN pd.COSTS_DST * ta.const1 / @const2
...
January 5, 2017 at 6:30 am
spectra (1/5/2017)
thats an impressive code !You are the SQL God.
Thanks for the quick post.
I am a relative noob, with sooo much to learn.
Just glad I could be of help.
January 5, 2017 at 5:54 am
spectra (1/5/2017)
I wish to add one condition in my code i.e a zero value checking .
like this ...
if(@const1!=0)
INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)
SELECT
@_id,
COSTS_DST*@const1/@const2,
'Y'
FROM PRIOR_DIST
WHERE _ID = @id_prev;
else
INSERT INTO...
January 5, 2017 at 5:39 am
You could also use a virtual tally table
declare @startdate DATE = '2016-04-01'
, @enddate DATE = '2016-04-30'
...
January 5, 2017 at 2:54 am
spectra (1/5/2017)
DesNorton (1/5/2017)
Is it possible to round the result up to 10 decimal place for the insert. Is there any way ?
What is the datatype of COSTS_DST?
If it is...
January 5, 2017 at 2:06 am
INSERT INTO PRIOR_DIST (_ID, COSTS_DST, IS_ACTIVE)
SELECT
@_id,
COSTS_DST*@const1/@const2,
'Y'
FROM PRIOR_DIST
WHERE _ID = @id_prev;
January 5, 2017 at 1:17 am
Take a look at the COALESCE function
January 3, 2017 at 11:11 pm
ma701ss (1/3/2017)
January 3, 2017 at 9:16 pm
It would appear that the [Id] field in AspNetUsers contains GUIDS.
However, your proc declares @userid as INT, and then tries to assign a GUID to an INT...
January 3, 2017 at 8:05 am
Is product not possibly a view?
December 19, 2016 at 9:33 pm
Viewing 15 posts - 1,231 through 1,245 (of 1,404 total)