Viewing 15 posts - 2,776 through 2,790 (of 4,087 total)
This type of request is usually best done in the presentation layer, such as SSRS or even an Excel Pivot Table.
If you insist on doing it in SQL you'll need...
March 11, 2016 at 1:07 pm
You usually use subqueries to create complex structures, although you can also use CROSS APPLY.
SELECT
1 AS SubmissionID,
1 AS OriginalUniqueSubmissionID,
'7-0' AS TestScenarioID,
0 AS CorrectedInd,
( SELECT
( SELECT 'TestData' AS BusinessNameLine1Txt FOR XML...
March 11, 2016 at 11:44 am
Something like the following:
-- do your first insert
INSERT ....
--conditionally do the second insert
IF @@ROWCOUNT = 0
INSERT ....
Here is the info about @@ROWCOUNT
Drew
March 11, 2016 at 8:26 am
sgmunson (3/10/2016)
drew.allen (3/10/2016)
sgmunson (3/10/2016)
March 11, 2016 at 8:17 am
sgmunson (3/10/2016)
March 10, 2016 at 3:24 pm
I think that you would be better off creating a view to do this than creating a computed column. In a view, you will be able to use FOR...
March 10, 2016 at 2:36 pm
All of the solutions provided leave open the possibility of a trailing delimiter, which may not be desirable. This (UNTESTED) solution will make sure there are no leading or...
March 9, 2016 at 8:41 am
MMartin1 (3/8/2016)
Consider something like this >
SELECT SUM(someNumberColumn) / (SELECT SUM(someNumberColumn) FROM Table) AS westCoastSalesAsA%OfTotal
FROM Table
WHERE someFilterColumn= 'west coast'
Could be done...
March 8, 2016 at 3:14 pm
I also considered the following in case he wanted zeroes last, but the rest in ascending order (assuming that OwnStaffID is never negative).
ORDER BY ProjID, SIGN(OwnStaffID) DESC, OwnStaffID
Drew
March 8, 2016 at 1:01 pm
To me, it looks like you want
ORDER BY ProjID, OwnStaffID DESC
This will sort by ProjID and within ProjID it will sort by OwnStaffID descending.
Dre
March 8, 2016 at 8:40 am
You have to remember that tables are sets and therefore inherently UNORDERED. You cannot depend on the presentation order to produce your desired results and there is no field...
March 8, 2016 at 7:55 am
You don't need to use cursors. As I said earlier, NTILE is your friend. Here is a solution that gets close. I'm dividing each major as evenly...
March 7, 2016 at 3:39 pm
Please don't cross post. It fragments the thread. Please continue on this thread.
Drew
March 7, 2016 at 11:23 am
It would help tremendously if you posted your whole query instead of just the one part. That being said, it sounds like you are using an absolute path instead...
March 7, 2016 at 11:20 am
I'm very cautious about automatically updating records like this, because there is so much variation for entering the same information. For instance, addresses with apartment numbers. If you...
March 4, 2016 at 8:43 am
Viewing 15 posts - 2,776 through 2,790 (of 4,087 total)