Laden...
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Precision and Scale II | |
What is the precision, scale, and length for an int variable? | |
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) |
The Rank Window I have this table and data: CREATE TABLE [dbo].[SalesTracking] ( [SalesDate] [datetime] NULL, [SalesPersonID] [int] NULL, [CustomerID] [int] NOT NULL, [PONumber] [varchar] (80) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [paid] [bit] NULL ) ON [PRIMARY] GO CREATE CLUSTERED INDEX [SalesTrackingCDX] ON [dbo].[SalesTracking] ([SalesDate]) ON [PRIMARY] GO INSERT dbo.SalesTracking (SalesDate, SalesPersonID, CustomerID, PONumber, paid, total) VALUES ('2024-03-15 10:45:55.067', 1, 1,'PO965' ,1, 100), ('2023-09-24 10:45:55.067', 1, 2,'PO627' ,1, 200), ('2022-07-02 10:45:55.067', 1, 3,'PO6' ,1, 300), ('2022-11-03 10:45:55.067', 1, 4,'PO283' ,1, 400), ('2022-11-26 10:45:55.067', 1, 5,'PO735' ,1, 500), ('2023-04-28 10:45:55.067', 1, 6,'PO407' ,1, 600), ('2022-09-09 10:45:55.067', 1, 7,'PO484' ,1, 700), ('2024-03-13 10:45:55.067', 1, 8,'PO344' ,1, 700), ('2024-04-24 10:45:55.067', 1, 9,'PO254' ,1, 800), ('2022-06-19 10:45:55.067', 1, 10,'PO344',1, 800) GOWhen I run this query, how many unique values are returned for the SaleRank column? SELECT st.SalesDate , st.SalesPersonID , st.total , RANK () OVER (PARTITION BY st.SalesPersonID ORDER BY st.total desc) AS SaleRank FROM dbo.SalesTracking AS st;Answer: 8 Explanation: There are 8 unique values: 1, 3, 5, 6, 7, 8, 9, 10. The RANK puts the same ordinal for tied values and then skips the appropriate number. Since there are 2 1s, 2 is skipped and the next value is 3. Ref: RANK - https://learn.microsoft.com/en-us/sql/t-sql/functions/rank-transact-sql?view=sql-server-ver16 |
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 - Development |
Execution Timeout Expired Error while executing an SQL query - Following error comes while executing an SQL query. Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. This happens after 30 seconds, even though I have set the Command Timeout property to 300 seconds. Here’s what I’ve already verified: The connection is working fine. I've […] |
SQL Server 2019 - Development |
IF then Else statement not exiting - I have an always on availability group of 3 servers (1 primary and 1 secondary (both on primary site) and the other secondary on DR site, as the only read-only secondary). A scheduled job runs every day that should only execute the tsql if the server is the primary derived from the 'sys.dm_hadr_availability_replica_states', here's my […] |
SQL Azure - Administration |
Replication from SQL Managed Instance to RDS - Is transactional replication from SQL MI to RDS SQL server supported. There isn't any documentation available from Microsoft. There are a few articles about replicating from Onprem SQL server to RDS or Azure SQL DB to RDS, I couldn't find anything for SQL Managed Instance. If not replication, are there any other options available for […] |
Microsoft's comparison to Azure DB vs Managed Instance - I'm migrating to the cloud from SQL Server 2016 to the cloud. On the list of differences between Azure DB and a Managed Instance, there are several features listed, such as DBCC, and DML Triggers where they say that Azure DB has "Yes, most". How can anyone find this as an acceptable answer. Any idea […] |
Storage Cost - What will be the storage cost 1 Managed Disk – S15; 256 GB HDD in Azure for DISK it costs around $11.33 per month in addition to that I want to know exact cost for 100IOPs for S15. Also it would be great one can share cost for E15 too. |
General Cloud Computing Questions |
what is the difference between these two queries - Please I am struggling to understand the difference between these two queries. It behaves differently as output google bigquery query 1 UPDATE dde-demo-d001.sap_crm.document_flow_root_bods SET case_guid = ICT.case_guid FROM dde-demo-d001.sap_crm.document_flow_root_bods DFR INNER JOIN dde-demo-d001.sap_crm.inferred_case_transactions ICT ON DFR.transaction_header_guid = ICT.transaction_header_guid WHERE DFR.case_guid IS NULL; query 2 UPDATE dde-demo-d001.sap_crm.document_flow_root_bods DFR SET case_guid = ICT.case_guid FROM (SELECT transaction_header_guid,case_guid FROM […] |
Text search emails and other json items - Problably SQL Server is not the best solution What would you use for searching lots of emails / jsons on specific terms? We're trying to provide a solution to business to allow to search if a specific mail is sent Like subject contains X sent around interval. Body contains Y |
Integration Services |
"External table is not in the expected format" - Good Afternoon. I have been manually running an SSIS package on an adhoc basis, which populates an Excel file from a SQL Server Table. There is no apparent issue with the package, but often I get the following error: "External table is not in the expected format" And it resolves when I Shut Down and […] |
Backups |
Hyper-V VM / Google Drive syncing issue - Hi everyone, I have a server running **Windows Server 2022**, named **"DATA SERVER"**. This server has two drives: **C and D**. What I Did: 1. **Enabled Hyper-V** and created a virtual machine (VM) called **"DATA VM"**. 2. Used **Disk2VHD.exe** to create **VHDX files** of the host machine's **C and D drives** and attached them to […] |
SQL Server 2022 - Administration |
Error when running sql server backup routine job - Guys, I am facing problems when running a backup routine JOB in SQL Server, when trying to run the JOB, it returns an error. When checking the JOB history, this message appears: Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 15.0.2000.5 for 64-bit Copyright (C) 2019 Microsoft. All rights reserved. […] |
error when trying to change replication settings - We have three servers that use SQL replication; PROD, BI, and PARTS. We have one database that replicates from PARTS to PROD and we have a around five databases that replication from BI to various Azure servers. We used to have a database called IRES that replicated from PROD to Azure - but we deleted […] |
SQL Server 2022 - Development |
Solution to a problem without using a CURSOR - Hi there to all SQL gurus So, here is the scenario. I have a #temp table in one of my SQL stored procedures which has only 2 columns, say Customer ID and Profile ID, and it has the below data Customer ID Profile ID 100001 […] |
Prepare Sum of Bill Amount Having two different status with fast performance - 1, Customer table [TBLMEMBER] 's structure CREATE TABLE [dbo].[TBLMEMBER]( [TRANNO] [int] IDENTITY(1,1) NOT NULL, [PARENTID] [nvarchar](10) NULL, [ACID] [nvarchar](10) NULL, [MEMBERID] [nvarchar](10) NOT NULL, [MEMNAME] [nvarchar](70) NULL, [PRINTNAME] [nvarchar](50) NULL, [GENDER] [nchar](10) NULL, [ADDRESS] [varchar](30) NULL, [DOB] [varchar](20) NULL, [PROV] [int] NULL, [GROUP] [nchar](2) NULL, [USERID] [nvarchar](15) NULL, [DISTRICT] [int] NULL, [PWD] [nvarchar](100) NOT NULL, […] |
sql server not responding - SQL server became slow before I ran exec sp_updatestats |
what happens to ssis and ssrs whenb we migrate to sql saas - Hi we know (or believe) ssas saas gets stood up separately when a company migrates to sql saas. But what happens to ssis and ssrs? from what i remember there is no such thing as ssis in azure. And the recommendation on sssrs is to move all those objects to pbi as paginated reports. we […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. [email protected] |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Laden...
Laden...