Viewing 15 posts - 1,411 through 1,425 (of 3,481 total)
SELECT c.CustomerID
, SUM(t.amount) AS TotalAmount
FROM Customer c
CROSS APPLY (SELECT TOP 2 o.*
FROM Orders o
WHERE o.Customer = c.CustomerID) t
GROUP BY c.CustomerID
HAVING SUM(t.Amount)>150;
September 10, 2017 at 12:43 pm
If you want YYYY - YYYY then you have to cast the Years as strings, otherwise, T-SQL will interpret the + as the addition operator. Check out CAST()
September 9, 2017 at 7:17 am
Welcome to SSC. It helps everyone if you post CREATE TABLE and INSERT scripts so people can run them and have at least a mockup of what you're dealing with....
September 8, 2017 at 11:16 pm
Rod,
if you have an HDMI port on your computer, send the signal to your TV. Just display some stuff on your computer screen and some on the TV. That's...
September 7, 2017 at 8:06 pm
This is trivial in SSRS.
Connect to your datasource, create your dataset, drop in a matrix.
People are on rows, Dates are on columns. Add a parameter for the start...
September 5, 2017 at 5:51 pm
You could use REPLACE(), but there are no spaces in that string to begin with.
DECLARE @TextWithSpaces VARCHAR(100) = 'I have a whole lot of spaces';
PRINT REPLACE(@TextWithSpaces,' ','');
September 5, 2017 at 12:52 pm
Looks like this works...
You may want to include other rows from both tables, but this should give you the gist of how to do it.use AdventureWorks2014;
September 5, 2017 at 10:00 am
Do you mean like this? (Note: I had to change your comparison date.)DECLARE @CurrTime DATETIME = '2016-09-09 18:13:00.000';
UPDATE #JobHistory
SET [Status]=2
WHERE ModifiedDate<=@CurrTime;
September 4, 2017 at 10:04 pm
But that leaves orphan records. Can you not populate the parent table first?
I supposed you could disable the check constraints, but why would you? Populating the child table...
September 1, 2017 at 1:27 pm
I did that with Store table (contains Surface Area), and Sales. I created a Total Surface Area measure = SUM(Store[SurfaceArea]) and put Store and SalesType on Rows, and Total Surface...
September 1, 2017 at 1:16 pm
Please explain what the measure you're creating is meant to calculate... and how it's meant to work. I think you may have a math error in your formula, but without...
August 30, 2017 at 7:41 pm
FFS, how about some real tables? Since you didn't provide consumable data, here's my best guess.
SELECT CM.cust_no
, loc_No
FROM Cust_Master CM
WHERE...
August 30, 2017 at 7:32 am
With a tally table, this is pretty easy:
DECLARE @max-2 INT;
SELECT @max-2 = MAX(Quantity) FROM #Test;
SELECT ID
, ProductCode
, Quantity
FROM #Test te
August 29, 2017 at 5:22 pm
DelimitedSplit8K would work, if you want that returned as a table (so each day of the week would be a record)...
August 23, 2017 at 12:40 pm
That's what I was gonna say... If I had the option, I'd do this in SSRS.. .Could do this in about 20 seconds.
August 23, 2017 at 8:13 am
Viewing 15 posts - 1,411 through 1,425 (of 3,481 total)