##Good things
Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here
##Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here
Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here
##Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set more sensible result set, e.g.:
enter image description here
##Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here
##Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here
##Good things
You use good local variables, and you are consistent with your naming. The typical naming for T-SQL is using PascalCase
, however there are no standards and snake_case
or camelCase
work just as good, as long as you are consistent (which you are).
You validate your values, although I am not quite sure why you chose 500 and 3 as arbitrary minimums (might be worth documenting).
###Results are not very useful...
As written, your query returns this:
ViewCount Score
--------- -----
571 10
629 5
685 6
721 10
728 11
761 12
840 25
849 7
870 17
888 9
1065 10
...
Which is all well and good, except, it doesn't give much information. Let's say we rewrite it a bit like this:
IF (@min_views >= @allowed_min_views AND @min_score >= @allowed_min_score)
BEGIN
SELECT
ViewCount
, Score
, [User Link] = @user_id
, [Post Link] = Id
, CreationDate
, [Tags] = Tags
FROM Posts
WHERE
PostTypeId = @question
AND OwnerUserId = @user_id
AND ViewCount >= @min_views
AND Score >= @min_score
ORDER BY ViewCount DESC;
END
Notice I changed ORDER BY
to DESC
, I think it makes more sense to show highest first.
Then we get a more sensible result set, e.g.:
enter image description here