473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to call multiple distinct groups of data?

Okay, simply put I need to write a query that will return x number of groups of y number of groups that each hold z number of records.

Example:
There are four teams (x)
with 15 team members per team (varying on the day) (y)
and we need to pull 350 records per team member (z).

Each team member needs to have a distinct set of 350 records from the database.

Help? Please?

Thanks!
Feb 16 '11 #1
9 2428
Rabbit
12,516 Expert Mod 8TB
You can use a subquery in the where clause to return the unique IDs of the top 350 records filtered by the parent query's team member.
Feb 16 '11 #2
Can you give me an example??
Feb 16 '11 #3
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Table1 AS x
  2. WHERE UniqueID IN
  3.   (SELECT TOP 10 UniqueID
  4.    FROM Table1
  5.    WHERE Category = x.Category
  6.    ORDER BY Sales DESC)
Feb 16 '11 #4
What I need to be returned is x number of distinct groups of 350 from the larger group that is being called. I need all of these groups to be returned at the same time, not one at a time. There is a distinct number per record (Caller ID), and the original group of records being called calls the records in order, but some Caller IDs are skipped (i.e.: 2,3,5,7,8,9,12). For each group of 350 records, I need to have the lowest and highest Caller IDs returned.

So, I need something like this returned:
1 – 350
351 – 700
701 – 1050
Feb 16 '11 #5
Rabbit
12,516 Expert Mod 8TB
I have no idea what you're looking for. Can you provide some sample data and expected results?
Feb 17 '11 #6
NeoPa
32,556 Expert Mod 16PB
Amy, using x, y & z is fine if your English is good enough, but without clearly specifying what you need you would be better advised using more meaningful terms. That way at least we'd have some form of context to fill in the gaps as to what you are trying to ask. I expect there are others, like me, who'd be only too willing to help if we but had a question we could understand.
Feb 17 '11 #7
Problem restated:

I have a database of several thousand records, I have 4 groups with 15 members each and I wish to write a query that will give each member a set number of different records to work on; so no member from any team should get any of the same records.
Feb 22 '11 #8
NeoPa
32,556 Expert Mod 16PB
It sounds like the groups is entirely inconsequential to the question. Am I right in thinking you have a table in a database with several thousand records in it and each record needs to be assigned to one, and only one, person (who happens to be a member of one of four distinct teams though this isn't relevant) from a pool of sixty such people? Also that the records need to be assigned evenly, such that the workloads of each person are similar?

As this seems somewhat inconsistent with your first post I won't assume I have this right until I get confirmation from you. I can say that if this is the situation then it's not a trivial problem, and will require some thinking about.

Presumably, if this is all correct, then you have a table in the database which contains references to each of the sixty people involved. If a record is to be assigned to a person then the ID for that person would need to be stored somewhere to indicate that the record has been assigned and to whom.
Feb 22 '11 #9
Rabbit
12,516 Expert Mod 8TB
It would help if you could provide sample data and results. But if I understand correctly and everything is sequential, you can use a mod 4 to assign the records.
Feb 22 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dean | last post by:
I want to build query to return how many rows are in this query: select distinct c1, c2 from t1 But SQL won't accept this syntax: select count (distinct c1, c2) from t1 Does someone know how...
5
by: SSP | last post by:
Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. Thanks in advance. SSP
2
by: Wei Wang | last post by:
Hi, Can I call multiple functions in one trigger? Something like this: CREATE TRIGGER match_cond_name_generate BEFORE INSERT OR UPDATE ON public.predicate_index FOR EACH ROW EXECUTE...
2
by: vvyshak | last post by:
Hi all... I have a table in which some columns has distinct values and some has duplicates..i wan to select all the columns with distinct values....no problem if rows has null value in it....i...
0
by: tolcis | last post by:
Hi! I need to know the proper way to split existing databases into multiple file groups. How do I move existing tables into different file groups (keeping all constrains intact) and move indexes...
13
LacrosseB0ss
by: LacrosseB0ss | last post by:
I was wondering, can an OnClick event of a button call multiple functions? The reason for this is I have a page that when "ok" is clicked, goes to a preview page before submitting data to the...
1
by: Query Builder | last post by:
I have one of our production Accounting Databases starting from 2 GB now grown into a 20 GB Database over the period of a few years... I have been getting timeouts when transactions are trying to...
2
by: ckrows | last post by:
I am attempting to create a report off of 6 option groups. Each option group is a Y or N response, populating a 1 or 2 in the tables. i want to report the number a word on the report, I chose the...
1
by: Will | last post by:
Hi, This is might be a basic question, but is it possible to hold multiple pieces of data in one field? I am adpating a database which compares multiple projects against a number of criteria....
3
by: deames | last post by:
I have an access report that combines project data with project planning considerations. It includes several sub reports and VBA coding on the on print function to print lines between the different...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.