Google Spreadsheet: SQL query to add more rows - sql

If I want to use a sql query to import around 2000 rows from the original google spreadsheet to another one. I will first have to manually keep adding/increasing the number of rows first in the sheet before I attempt to import the 2000 rows.
Example sql query,
=QUERY('Experts'!A:Z,"Select A,C,M where M <=date """&text(H3,"yyyy-mm-dd")&""" and L='Yes' ")
Is there anyway for me to be able to use this query directly without first having to manually increase the number of rows to accommodate the imported data?

You do not need to manually add rows, the query function will do it for you.

Related

How to delete rows by calling its row number

I have this data stored in the SQL Server
How can I delete the first three rows by calling the row number found in the left (1,2,3)?
You can't. That row number is not tangible and is nothing more than the order the results were returned in. SQL does not guarantee order of data, so there is no rule that says if you run the same query 20 times, you'll get the same results at 1,2, and 3 each time. That's not to say you won't get them same results, they're just not guaranteed. You need to delete using a column that actually exists as part of the table definition, such as F1, F2, etc...
As others have suggested in the comments, try to clean up the data before you import it into SQL Sever. You have a few options.
Delete the rows from the file before importing.
Configure the Import Wizard correctly to exclude those rows.
Helpful link
https://learn.microsoft.com/en-us/sql/relational-databases/import-export/import-data-from-excel-to-sql?view=sql-server-ver15

One column per report page

I have a 4x4 table in SQL with 20 rows. I want to split this data into four pages. Page 1 has the first 10 rows of the first column, Page 2 has the first 10 rows of the second column, etc.
After every four pages, this patern repeats showing the next 10 rows from the first column, etc. How can I arrange this?
I could arrange the data of the 4x4 table into another temporary table with just one column in its schema. Then I could read a single column of this table into my report. But can I instead do this directly without an intermediary table?
The intermediary table sounds like the best solution to me. I'd just write a custom SQL command in Crystal's Database Expert to arrange the data as you see fit.
You could in theory pull this off with repeating subreports in some manner of repeating header, but it would be much less work to have SQL properly format the incoming data for you.

sorting BIG excel data

Right so, I have been given a LOT of "consumer data" to sort, 3 excel files, each containing multiple worksheets, up to 7 worksheets, each up to 1M rows (max worksheet size in excel 2013 is just over 1 rows)
I need to pull out of these all people within a region, so have a list of post codes in this region (say 30 post code areas)
How can I achieve this most easily?
If the data was in SQL server, i'd just write a long SQL statement selecting all where postcode LIKE 'B75'% OR 'B74'% etc etc.
But in excel I can only run a "filer" on one worksheet at a time... (I think)
Is it going to be easiest to throw all the data into sql server, or have I overlooked a method?
First solution is to let Excel do the task of sorting for you. You need to add filters to columns and select Sorting options.
Other solution is to Export Data to SQL Table(s). To do this, Open SQL Management Studio, Right Click on Database to which you want to export data to and Select "From Excel File". Do this for each Excel file you have. After importing all data in Database, sort Data using SQL Query.
Second Solution is reliable but first solution is faster. You need to decide which one you should select.

best aproach to distinct query result before importing it into Excel cells

I have a query which grabs data from Access with contents:
A,1,z
A,2,z
B,1,y
A,1,i
I created 3 dropdowns in excel and I want to populate them with rows from these columns. The problem is that in each column there are duplicates and I want to get rid of them. I am looking for a solution to get rid of these duplicates.
Current process is following:
run a query. I use VBA in Excel. Access is being queried.
paste results into a separate sheet (it takes A LOT of time because there are 20k reocrds)
assign a range for my dropdows
As you can see my second step is very resource hog and the proccess time should drop drastically by removing duplicates from each column.
What is the best approach to populate dropdowns with unique values from query?
My ideas
create a query which will output me:
A,1,z
B,2,y
, ,i
In that case i will not have to distinct values manually in excel. Not possible to do, as I understand...
Add values from each columns to List, remove doubles, paste result into excel. This is my personal favorite because I see no other ways to fix the issue.
create multiple queries to DISTINCT each table_column separately.. Not very fast solution, I suppose
some other approach
Run three SELECT DISTINCT Colx FROM table queries to get the values for the three dropdowns. Your option two. The work has to be done sometime so you might as well use the tools designed to do the work instead of reinventing that wheel.
If you use select distinct columna, columnb... instead of select columna, columnb... you will get what you want. The SQL will take longer to run, though.

Export from Query to Excel, while defining Row to export to

I have seen a bunch of ways to export data into excel worksheets form queries, yet I cannot find one that I can define the starting row I would like the insertion of the query data to begin.
For example, I would like the first 5 columns of my query to go into columns A8-F8, and the rest of the columns from my query to go into columns H8-Y8.
Is there a way to specify where my data from the query should start pasting, and the starting row as well?
You could add a null value for the 6th position of your query.