is it possible to add a select in a return statement? I tried adding the select name from skills where skill_id = 1 but not sure if this is possible or I just don’t have the syntax right. Answer Yes, that is possible, but you have to enclose a subquery in parentheses:
Tag: sql
Returning Records by Week
I’m trying to come up with a way to return a result set from the below data without a loop that shows the number of records by Team for a particular date range by week. I’ve got a Date table (https://www.mssqltips.com/sqlservertip/4054/creating-a-date-dimension-or-calendar-table-in-sql-server/) that has every day/week/year referenced, but not sure how to connect it up. I’ve got this query: Where it
Get all dates of a Year based on Day Name [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I want to take all Dates of an year based on Day Name. For example If I pass Thu/Thursday and
SQL Server – Add a linked server to AWS RDS instance
From this AWS link it explains how to add a linked server: https://aws.amazon.com/blogs/database/implement-linked-servers-with-amazon-rds-for-microsoft-sql-server/ Specifically these commands The main problem is it seems to be a mix of ‘, `, and ” I get syntax errors, and I assume that’s why. Plus, I don’t know why it has the N before a bunch of them. It looks to me like they
SQL agent job creation error: Job ‘XXX’ is already targeted at server ‘YYY’
I am trying to create and SQL agent job on SQL Server 2016. Here is the use of sp_add_job. EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N’TEST_RUN_A_JOB_STEP’, @enabled=1, @…
AWS Athena: Unsupported correlated subquery type but it works on Mysql and other flavors
For each order in orders table, I’m trying to return the latest order update value based on time_sent, grouped into a single row. The above select query works fine in MySql but not in AWS Athena. Working MySQL example below: https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=66f17cf9f3c8f19f758c7cb1381d8207 Is there a way to accomplish the above using joins? Answer It’s possible to achieve this with Window Functions
how to merge multiple rows into single in MSSQL
this is my data: id segment country product status month year 83916512 Government Null Null Null Null 2014 83916512 Null Germany Null Null Null 2014 83916512 Null Null Carretera Null Null 2014 83916512 Null Null Null completed Null 2014 83916512 Null Null Null Null June 2014 83916512 Null Null Null Null Null 2014 i want below output can anybody help
how i get my 2nd id in the join table in mysql
SELECT package.pkg_name, pkg.cat_id,pkg.id FROM pkg INNER JOIN package ON pkg.id=package.id join categories ON pkg.cat_id=1=categories.cat_id=1 1st id is show in join table but 2nd id does not show …
REGEXP to identify and replace an email
long story short, I need to identify an email that may have 2 different endings: “HREmail@companyabc.com” “HREmail@company.com” I need to replace instances of the two above …
SQL SERVER Replace Null
I have a tsql query like that: DECLARE @TABLE TABLE( id int primary key identity(1,1), code int ); INSERT INTO @TABLE VALUES (1),(NULL),(NULL),(NULL),(2),(NULL),(NULL),(NULL),(3),(NULL),(NULL)…