Laden...
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Getting Subtotals | |
I am testing some aggregations and have this setup code: CREATE TABLE ProductSales ( SaleID INT IDENTITY(1,1) NOT NULL CONSTRAINT ProductSalesPK PRIMARY KEY , ProductCat VARCHAR(100) , ProductName VARCHAR(100) , SaleDate DATETIME , SaleTotal NUMERIC(10,2) ) GO INSERT dbo.ProductSales (ProductCat, ProductName, SaleDate, SaleTotal) VALUES ('Laptop', 'HP Spectre', '2020-01-02', 100 ), ('Laptop', 'Lenovo Thinkpad', '2020-01-05', 200 ), ('Laptop', 'AlienWare', '2020-02-02', 300 ), ('Mobile', 'iPhone', '2020-02-12', 50 ), ('Mobile', 'Samsung Galaxy', '2020-03-12', 100 ), ('Watch', 'Apple Watch', '2020-02-22', 200 ), ('Watch', 'Garmin Forerunner', '2020-02-23', 400 ) GO I want to run a sum by month. I have this code: SELECT ps.ProductCat , MONTH(saledate) , SUM(ps.SaleTotal) AS TotalSales FROM dbo.ProductSales AS ps GROUP BY ps.ProductCat, MONTH(saledate) WITH XXXX Which keyword(s) replaces the XXXX and gives me less rows in the result set? | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
Partitioning Heaps Can I partition a heap table? Answer: Yes Explanation: Yes, you can partition a heap, like you would any other table. Ref: Heaps - https://docs.microsoft.com/en-us/sql/relational-databases/indexes/heaps-tables-without-clustered-indexes?view=sql-server-ver15 CREATE PARTITION - https://docs.microsoft.com/en-us/sql/relational-databases/partitions/create-partitioned-tables-and-indexes?view=sql-server-ver15 |
Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
SQL Server 2017 - Administration |
Upgrading from SQL Server 2012 to SQL Server 2017 - Any Tips or Gotchas - We are running SQL Server 2012 SP4 Standard Edition on Windows Server 2012 R2 Standard Operating System. We would like to do an in-place upgrade to SQL Server 2017 in a non-production environment using the Developer Edition. Are there any tips, pitfalls, or gotchas that we should be aware of. Please share anything that may […] |
Administrating Analysts - Hi Guys, I was just wondering if any of you guys would be willing to share your experience or have any advice on how to manage a situation we are seeing. So we have a back end data warehouse, fairly standard setup with an overnight load and SSRS reports etc. We also have a bunch […] |
Host database - I have database currently sharing with other DB's. I don't have any issues at this point in terms of performance.The only problem is it's standalone. If ever it goes down then there would be impact on the application. So is that a good option to have db on it's own server instead of sharing with […] |
SQL Encryption - I am looking at encrypting some of the data was wondering if you have used encryption and looking for any inputs and thoughts based on there use. Thanks in advance! |
SQL Server 2017 - Development |
Expression expression runtime failure in SSIS - Hi Team, I have the following expression in ssis and the value of @[User::ExecutionId]=12dfg "##stg_mdif_"+ @[User::ExecutionId] I need the final expression to be "##stg_mdif_12dfg".I tried different ways to parse it but SSIS expression is failing. Please let me know if you need any further information. |
Query taking more than 4 hrs. - Any recommendations/suggestions? - One of our stored procs has been running for more than 4 hrs. and we have to finally kill it as it is taking quite and causing blocking...also this shouldn't take this long....we've come to a point and identified the batch of code that is causing the problem. Our indexes and stats are all tuned […] |
Get all information from within a trigger - Hello from Portugal. I manage a database for a customer, and this database has been developed and used from a fistful of developers and many programs, since it is living for about 209 years now. This database has a main table, where many information are in. We now have faced the fact, that anything is […] |
SQL Server 2016 - Administration |
SQL 2016 and 2017 on same machine? - Long story, I'll spare the details. I have a machine with SQL 2016 Standard installed. I would also like on a short term basis to install SQL 2017 Developers on the same machine; without it "breaking" the 2016 version. Is this possible? Thanks! |
Development - SQL Server 2014 |
Function test questionnaire help - qq Hi clever people! The following is part of a TEST QUESTIONNAIRE. Although in the following two part question it seems silly to create a function and there are other, better ways to do this the test questionnaire is about CREATING A FUNCTION. Please bear that in mind. The following are the two tables followed […] |
SQL Server 2019 - Development |
Unusual use of the WHERE clause - I am working an exercise problem where the solution provided has a WHERE clause used in a way I have not seen before. The question asks, "to show the name and numbers of all salesmen who had more than one customer." Although the SQL online documentation shows an example of using WHERE with a comparison […] |
XML parsing/shredding - Hello, not sure if this is the right subform to post this in, but anyhow... I have a few tables that all has a column with an XML datatype in it, with lots of data this column. Each of these tables has about 10-20 million rows. The XML data structure is pretty simple but has […] |
SQL Server Newbies |
Calculate Target Column - Hi, I have below table Sum of AP1 = 1764. I need to sql query to calculate Target column for Week Number .Please help to calculate |
General |
What should be the Data Type for the list of columns below for effective queryin - Hi all, I want to get the basics right, and I am in the middle of pulling 1 million rows approx into a table below. For effective querying in the future can someone please advise the data types I should use for the below columns when creating initial table. I have displayed an example of […] |
Analysis Services |
How to get the SSAS Server administrators in MDX query? - Hello, Is there any way to get the list of server administrators from SSAS in MDX query? Thanks |
COVID-19 Pandemic |
Daily Coping 2 Jul 2020 - Today’s tip is share a happy memory with someone who means a lot to you. http://voiceofthedba.com/2020/07/02/daily-coping-2-jul-2020/ |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Laden...
Laden...
© 2024