I have a good friend who loves using excel. I want to encourage her to learn some SQL and database queries. In this post, I will share the most important bridge from my known/familiar territory to my new territory. My “secret” bridge is GOOGLE. With the correct google search term set (utilizing one’s known knowledge), google will give answers that applicable to the unfamiliar knowledge. Little by little, and piece by piece, the knowledge of unfamiliar field become familiar and known. Today, the known territory is “Excel”. The new territory is “SQL”.
Continue reading “Bridges between Excel and SQL”
What is the two most important words that one should look for in SQL Server Execution plan? Scan ! Seek!
SCAN a big table is a disaster. The rescue is: try your best to let SQL Server SEEK a big table.
(William Wolf taught me this many many years ago at a SQL Saturday meeting. This knowledge is so powerful and it makes one of my query work so good that I want to share with you.)
Continue reading “Trick SQL Server to use the best Execution Plan”
Dynamic is one of my favorite search words. It is the opposite of “static”. A lot of time, SQL statements requires static input, such as column name and table name in SELECT. However, Dynamic SQL gives a way to overcome this requirement. This post I will share with you other two usages of ‘dynamic’.
Continue reading “Dynamic! Dynamic!”
Window functions of SQl server are very useful. Many webpage like this one https://www.brentozar.com/sql-syntax-examples/window-function-examples-sql-server/ have written how to use them. I want to share with you one segment of my sql code to get running total percentage using window functions.
Continue reading “Running Total Percentage”
It worked finally. My 12 queries was now 1 query. I only need to run it once to give my result. Yeah!
What did I do to make it work? I made an extra layer. First layer, select the result set as before. Then, select these result set and add rowID. Thirdly, select second layer result set by joining RowID.
Continue reading “Query Result side by side. Yes, finally!!”
I have twelve queries. Each of the query select 20 random account numbers that fits its own special where clauses. For twelve times, I need to copy the SQL code in TOAD, run the query in DB2, copy paste the 20 lines of result to one final excel file, which contains twelve columns.
Of course, I want to change it. I think it should not be too difficult.
Continue reading “query result side by side? NO!”
My kids and I love tongue twisters. We say tongue twister loudly in the car and they giggle and laugh loudly. I love to hear them giggle and laugh.
As I work full time as a SQL developer, I write and read SQL code much more often than when I was a SQL blogger. When I see SQL some code, I think: this is good. But, can you find a better way? Furthermore, what is the best way? These questions tickle my brain and when I find some answer, my brain giggles and laughs. I love that feeling.
Today, I want to share two SQL brain twisters (that comes from my work) with you. Continue reading “Brain Twister in SQL”
I think these following steps are good for the exam preparation:
Continue reading “Preparation for Microsoft Exam 70-761”