Ask Programiz - Human Support for Coding Beginners
Explore questions from fellow beginners answered by our human experts. Have some doubts about coding fundamentals? Enroll in our course and get personalized help right within your lessons.

That's a great question!
Working with SQL is different from entering data into Excel because, with SQL, you don't manually type or organize the data yourself.
Instead, the data is already stored in a database, and you use SQL commands to find, retrieve, organize, and analyze that data automatically.
In Excel, you often work with small amounts of data by hand. In SQL, you can work with huge amounts of data much faster and more efficiently using simple queries.
If you have more questions, I'm here to help!


Hi there! ROWS BETWEEN can be a bit confusing at first, so let’s break it down together.
First, ROWS BETWEEN
is not actually a window function itself. Instead, it's a clause used inside a window function to define which rows should be considered for the calculation. It's like setting the boundaries or frame for your data analysis.
When you see the code
AVG(closing_price) OVER (
ORDER BY date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
)
The part "ROWS BETWEEN 6 PRECEDING AND CURRENT ROW" tells SQL to calculate the average of the current row and the past six rows, effectively allowing us to compute a 7-day moving average.
By specifying these boundaries, SQL knows how far back or forward to look from each row in the dataset when performing the calculation.
Hope this helps make things clearer! Feel free to ask if you have any more questions.

When using PARTITION BY
and ORDER BY
in SQL window functions, the order of these clauses inside the OVER()
is very important—and here's why:
LAG(age) OVER (PARTITION BY country ORDER BY age)
PARTITION BY
comes first because it splits the data into groups (partitions) based on the specified column (in this case,country
).
Think of it like creating smaller, isolated "mini-tables" within your result set for each country.ORDER BY
comes after, because once the data is partitioned, you need to define the order within each partition.
Functions likeLAG
andLEAD
depend on the order to know which previous or next row to reference.
Now, your code doesn't run because you have placed ORDER BY
first before PARTITION BY
. However, SQL needs to know the groups before it can order within those groups.
Hope this helps!

In SQL, wildcards like %
and _
are mainly used with the LIKE
operator inside a WHERE
clause to perform pattern matching and filter results.
Without the WHERE
clause, wildcards don't really have any effect—because there's no condition to apply them to. Their purpose is to match values against a pattern, and that only happens when you're telling SQL what to search for.
For example:
SELECT * FROM customers
WHERE name LIKE 'A%';
This query returns all customers whose names start with the letter "A"
. The %
wildcard matches any number of characters after "A"
.
Without the WHERE
clause:
SELECT * FROM customers;
You're simply selecting everything—no pattern-matching is happening here, even if wildcards exist elsewhere (e.g., in a computed column or subquery, but those are more advanced cases).
So, to answer simply: wildcards are useful only when combined with LIKE
(or sometimes NOT LIKE
) inside a WHERE
clause, where they serve their purpose of filtering based on patterns.

The difference between SQL and SQL server is simple:
SQL (Structured Query Language) is a language used to interact with databases. It allows you to retrieve, insert, update, and delete data. This is what you'll be learning in this course.
SQL server, on the other hand, is a database management system (DBMS). It's a software that stores, organizes, and processes data, allowing you to execute SQL commands efficiently.
For example,
SELECT * FROM Customers;
If you run this command, SQL Server is the system that reads this SQL command, fetches the data from the database, and gives you the result.
Think of it like this: SQL is the language, and SQL server is a tool that understands and runs SQL commands.
Note: Besides SQL Server, there are other popular database systems too like MySQL, PostgreSQL, and Oracle DB. They all use SQL (with slight differences), but are different pieces of software.


The use of %d
and %d%
is related to the LIKE
operator, which is used to search for a specified pattern in a column. The %
character is a wildcard that can represent any sequence of characters (including no characters at all). Here's how they work:
%d
: This pattern is used to find values that end with the letter 'd'
. For example,
SELECT * FROM table WHERE column LIKE '%d';
This will return all rows where the column
ends with the letter 'd'
. For example, it would match "keyboard"
, "mousepad"
, and "sand"
.
%d%
: This pattern is used to find values that contain the letter 'd'
anywhere in the string. For example,
SELECT * FROM table WHERE column LIKE '%d%';
This will return all rows where the column
contains the letter 'd'
at any position in the string. For example, it would match "ride"
, "window"
, and "card"
.

Yes, there's a difference between using SELECT *
and SELECT
without *
in SQL. Here's how they work:
1. SELECT *
The *
means "select all columns" from a table. For example,
SELECT * FROM employees;
This will return all columns from the employees
table.
2. SELECT
without *
(Selecting Specific Columns)
Instead of selecting all columns, you can specify the columns you need. For example,
SELECT name, age FROM employees;
This will return only the name
and age
columns, ignoring others.
Note: In real-world applications (especially large databases), it's generally recommended to select only the columns you need instead of using *
. This improves performance and reduces network load.