I'm currently using the following SQL query which is returning 25 rows. How can I modify it to ignore the first row:
SELECT fiscal_year, SUM(total_sales) as sum_of_year, AVG(SUM(total_sales))
OVER () as avg_sum
FROM sales_report
GROUP BY fiscal_year
ORDER BY fiscal_year ASC
I'm using SQL Server 2008.
Thanks.
Select entire column (including or excluding blank cells) except header with Kutools for Excel If your list does not contain any blank cells, you can use the shortcut to select entire column but the first row.
Selecting rows where the column is null or not. Let’s select rows where the 'Dept' column has null values and also filtering a dataframe where null values are excluded. First, we did a value count of the column ‘Dept’ column. The method .value_counts () returns a panda series listing all the values of the designated column and their frequency.
The most simple one is by builing a list of rows which to be skipped: As you can see read_csv method keep the header and skip first 2 rows after the header. Parameter skiprows is defined as:
Select entire column (including blank cells) except header with VBA. Also, besides the Define Name function, you can use VBA to select entire column but first row. 1. Select a cell of the column you want to select and press Alt + F11 to open the Microsoft Visual Basic for Applications window.
You can use EXCEPT
in SQL Server 2008.
SELECT fiscal_year, SUM(total_sales) as sum_of_year, AVG(SUM(total_sales))
OVER () as avg_sum
FROM sales_report
GROUP BY fiscal_year
EXCEPT
SELECT TOP 1 fiscal_year, SUM(total_sales) as sum_of_year, AVG(SUM(total_sales))
OVER () as avg_sum
FROM sales_report
GROUP BY fiscal_year
ORDER BY fiscal_year ASC
For SQL Server 2012 and above, you can use FETCH OFFSET
assuming this is exactly how you'd query it, then:
SELECT fiscal_year, SUM(total_sales) as sum_of_year, AVG(SUM(total_sales)) OVER () as avg_sum
FROM sales_report
WHERE fiscal year <> (SELECT MIN(Fiscal_year) FROM sales_report))
GROUP BY fiscal_year
ORDER BY fiscal_year ASC
And then you can remove the "order by".
Works on all versions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With