473,386 Members | 1,702 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,386 software developers and data experts.

Scalar Subquery in MS-SQL Server 2000

Hi Gurus,

I have table (CallByCall) with following Data.

Input :
CallID Event DNIS UserID Time SeqID MobNo
-----------------------------------------------------------------------------
1 | 43 | 100 | |09:00:05 | 1 |
9833210770
1 | 40 | | |09:01:05 | 2
|
1 | 41 | | |09:02:05 | 3
|
1 | 42 | | 25 |09:03:05 | 4
|

2 | 43 | 200| |09:10:05 | 1 |
9833975536
2 | 40 | | |09:11:05 | 2
|
2 | 41 | | |09:12:05 | 3
|
2 | 42 | | 26 |09:13:05 | 4
|

3 | 43 | 300| |09:15:05 | 1 |
9813978536
3 | 40 | | |09:15:55 | 2
|
3 | 41 | | |09:16:05 | 3
|
3 | 42 | | 28 |09:18:05 | 4
|

4 | 43 | 100| |09:45:05 | 1 |
9223978896
4 | 40 | | |09:46:05 | 2
|
4 | 41 | | |09:47:05 | 3
|
4 | 42 | | 26 |09:48:05 | 4
|

Output:
CallID DNIS UserID MinTime MaxTime MobNo
--------------------------------------------------------------------------
1 | 100 | 25 |09:00:05 |09:03:05 |9833210770
2 | 200 | 26 |09:10:05 |09:13:05 |9833975536
3 | 300 | 28 |09:15:05 |09:18:05 |9813978536
4 | 100 | 26 |09:45:05 |09:48:05 |9223978896

In short I am getting DNIS and MobNo for Event 43 and
UserId for Event 42.

How can I achieve the above result?
Is it possible with scalar query?

Could any one help me for the same?

Thanking in Advance
Sanjeev
98332 10772
Mar 28 '08 #1
1 2545
"Sanjeev" <sa**************@gmail.comwrote in message
news:f4**********************************@e23g2000 prf.googlegroups.com...
Hi Gurus,

I have table (CallByCall) with following Data.

Input :
CallID Event DNIS UserID Time SeqID MobNo
-----------------------------------------------------------------------------
1 | 43 | 100 | |09:00:05 | 1 |
9833210770
1 | 40 | | |09:01:05 | 2
|
1 | 41 | | |09:02:05 | 3
|
1 | 42 | | 25 |09:03:05 | 4
|

2 | 43 | 200| |09:10:05 | 1 |
9833975536
2 | 40 | | |09:11:05 | 2
|
2 | 41 | | |09:12:05 | 3
|
2 | 42 | | 26 |09:13:05 | 4
|

3 | 43 | 300| |09:15:05 | 1 |
9813978536
3 | 40 | | |09:15:55 | 2
|
3 | 41 | | |09:16:05 | 3
|
3 | 42 | | 28 |09:18:05 | 4
|

4 | 43 | 100| |09:45:05 | 1 |
9223978896
4 | 40 | | |09:46:05 | 2
|
4 | 41 | | |09:47:05 | 3
|
4 | 42 | | 26 |09:48:05 | 4
|

Output:
CallID DNIS UserID MinTime MaxTime MobNo
--------------------------------------------------------------------------
1 | 100 | 25 |09:00:05 |09:03:05 |9833210770
2 | 200 | 26 |09:10:05 |09:13:05 |9833975536
3 | 300 | 28 |09:15:05 |09:18:05 |9813978536
4 | 100 | 26 |09:45:05 |09:48:05 |9223978896

In short I am getting DNIS and MobNo for Event 43 and
UserId for Event 42.

How can I achieve the above result?
Is it possible with scalar query?

Could any one help me for the same?

Thanking in Advance
Sanjeev
98332 10772
Try this:

SELECT CallID,
MAX(DNIS) DNIS, MAX(UserID) UserID,
MIN(Time) MinTime, MAX(Time) MaxTime
FROM CallByCall
GROUP BY CallID;

--
David Portas
Mar 28 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin MacRobert | last post by:
Hi, I'm trying to make a specialisation of a template function, so that the second parameter accepts scalar types only (int,double,float etc.). How can I do this without writing an explicit...
2
by: Greg Stark | last post by:
I find I often want to be able to do joins against views where the view are aggregates on a column that has an index. Ie, something like SELECT a.*, v.n FROM a JOIN (select a_id,count(*) as n...
0
by: Greg Stark | last post by:
Postgresql 7.4b2 (approximately, compiled out of CVS) When I have a subquery that has a complex subquery as one of the result columns, and then that result column is used multiple times in the...
5
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
22
by: Kevin Murphy | last post by:
I'm using PG 7.4.3 on Mac OS X. I am disappointed with the performance of queries like 'select foo from bar where baz in (subquery)', or updates like 'update bar set foo = 2 where baz in...
5
by: Eli | last post by:
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about...
3
by: laurentc via AccessMonster.com | last post by:
Hi. I have an issue with my Access project. I have rather big tables of data (about 11 000 rows). These tables are historical product quotations, so they are very simple : - MyDate...
3
by: Shals | last post by:
Hi, I'm using Form and a subform control within that form. Main form is getting data from one table(Buildings) and subform is getting data from another table(BldgDataByFloor). but both the form...
13
by: ThePrinceIsRight | last post by:
I have a problem with using a subquery in MS Access. The purpose of the sub-query is to create a list of people who have had doctor exams in the past 6 months and exclude them from the main query....
2
by: nshishir | last post by:
In oracle, there is a performance improvement if scalar subqueries are used instead of joins. Does this hold good for Db2 (8.2) too?
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.