Skip to content
Advertisement

TSQL-ORDER BY clause in a CTE expression?

Can we use ORDER BY clause in a CTE expression? Error message: Msg 1033, Level 15, State 1, Line 14 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. Msg 102, Level 15, State 1, Line 25 Incorrect syntax near ‘,’. Answer You

What’s the default window frame for window functions

Running the following code: The result is: There is no window frame defined in the above code, it looks the default window frame is rowsBetween(Window.unboundedPreceding, Window.currentRow) Not sure my understanding about default window frame is correct Answer From Spark Gotchas Default frame specification depends on other aspects of a given window defintion: if the ORDER BY clause is specified and

Heap big table with performance issues

I have a business case where I need to store all details about invoices from vehicle workshop (invoice number, dealer,vehicle number, peace, nature of service , …). I have more than 50 columns which are all selected in the same query. In my treatment I need to do some specific treatment in order to get cleansed data and some basic

How to create Audit history table table [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 5 years ago. Improve this question I have a stored procedure which update records. Can anyone help me how to create an audit table that will

Use mid and inner join SQL query in VBA excel

Please find the below table where i want to execute mid and inner join SQL query. table 1:- table 2:- Please find my below syntax and the respective error’s which i am facing on the same. 1st sql …

Adventure Works 2014 SQL Queries

I am writing a SQL query using Adventure Works 2014 database. I want to show all customers and how many orders each customers have. I tried to write each select statement by itself (see below), but I’d like to be able to combine both queries into one. Answer

States where the number of suppliers exceeds the number of consumers

I’m working on trying to get states where the number of suppliers is greater than the number of consumers in those states. Here is the code I’m tryin to get working: When I exclude the having clause I get the following results: The code is giving me no results. Also here is a snapshot of the database diagram. Answer Use

Advertisement