Scripts

Technical Article

Restrict simultaneous access to resources

This set of procedures allow you to control simultaneous access to any resource you are using. It mimics the behaviour of a Semaphore in programming.A typical problem where you need this, is when you have a computational intensive procedure you only want to be started a limited number of times.First, add a record to the […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2003-05-07

323 reads

Technical Article

Returning data with col number

This script enables you to return data from SQL Server's table without specyfing the name of the column .All you only need to supply is the column number, that you want the data from. In the example we want to chose all rows from the second column (categories table - northwind) Column number is based […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2003-05-07

204 reads

Technical Article

UDF to get first date or trim time for Datepart.

Not long ago I was in a forum discussion when someone presented another way to get the date with time value of midnight by doing similar to thisDATEADD(dd,DATEDIFF(dd,0,@DATE),0)Which I find is much cleaner than any other option I have seen or tried myself. Seeing this I realized there are many other dates that can be […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

(1)

You rated this post out of 5. Change rating

2003-05-02

532 reads

Technical Article

fnArabToEnglish

Last year I pulished a function ,named fnArabToEnglish,which can convert a arabic number to english ,such as turn 1234.56 to 'one thousand two hundred thirty four and cents fifty six'.Mr Rick send me a message with a bug of thefunction today,I get rid of the bug and publish the second time.I hope you like this […]

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2003-04-30

109 reads

Blogs

November 2026 Car Update: MPG Comparisons

By

I’ve become an EV guy. I was talking with a friend who was selling...

Memories of PASS Data Community Summit 2026

By

A bit of a photo dump, but a few fun memories for me from...

What's New in SQL Server for the Developer: SQL Server 2016

By

Part 2 of my What's New in SQL Server for the Developer series. STRING_SPLIT,...

Read the latest Blogs

Forums

How to connect your SQL Server 2025 semantic search for free

By Daniel Calbimonte

Comments posted to this topic are about the item How to connect your SQL...

Finding the Black Friday Sales Ranking

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Finding the Black Friday Sales...

I wonder about this interesting event - Windows keys

By skeleton567

Earlier this week I had an issue with a Win 8.1 laptop I was...

Visit the forum

Question of the Day

Finding the Black Friday Sales Ranking

We are tracking sales for Black Friday today. We have these aggregate values:

CREATE TABLE dbo.BlackFridaySales
(
    Product NVARCHAR(50) NOT NULL PRIMARY KEY,
    Units   INT          NOT NULL
);

INSERT INTO dbo.BlackFridaySales (Product, Units)
VALUES (N'55" TV',          900),
       (N'Air Fryer',       500),
       (N'Noise-Cancel Headphones', 500),
       (N'Robot Vacuum',    300);
I'm trying to get a ranking of the sales that would return 1, 2, 2, 3 for the product levels. Which query does this?

See possible answers