Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Selects in one row

Status
Not open for further replies.

DvDvDvDv

Programmer
May 24, 2001
100
PT
I'm doing different select statements in multiple tables (all connected with the same field).

I need to return all selects in one row.

Information: I don't want to make it in only one select statement, but use all of them.

What is the best way to proceed in MSSQL ??????

Please help me

Dv
 
Can you provide more details on your problem?
i.e.
- what does your current query llok like?
- what does the resultset currently look like?
- what do you want it to look like?
 
I just re-read your original post. Am guessing you're desiring something like this using subqueries?

Select Cola as Item1
(Select ColB from TableB) as Item2,
(Select ColC from TableC) as Item3,
(Select ColD from TableD) as Item4,
From TablaA

Is this close?
 
I'm really unclear of your requirement. Can you post the queries, the table structure, sample of the data in the tables and the expected result? Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Hi,

I'm converting some Oracle sql statements to MSSQL, like this:

1 groups
group_start= 0, group_end=18
SELECT DISTINCT assoc.* FROM ign_an.assoc assoc WHERE assoc.orid in (320023 320049, 320065) AND assoc.phase NOT IN ('NLR','NP')
SELECT DISTINCT a.sta,a.time,a.arid,a.chan, a.azimuth,a.slow,a.amp,a.per,a.fm,a.snr,a.auth,a.commid, NVL(TRANSLATE(x.clip,x.clip,'a'),'m') picktype FROM ign_an.arrival a, ign_an.assoc assoc, ign_an.arrival x, ign_an.origin o WHERE a.arid = assoc.arid and a.arid=x.arid(+) AND o.orid=assoc.orid AND assoc.phase not in ('NLR','NP') AND o.orid in (320023 320049, 320065) AND o.time between 1016339182.348640 - 1 and 1016476207.200850 + 1
SELECT DISTINCT stamag.* FROM ign_an.stamag stamag WHERE stamag.orid in (320023 320049, 320065) and stamag.magdef='d'
SELECT DISTINCT netmag.* FROM ign_an.netmag netmag WHERE netmag.orid in (320023 320049, 320065)
SELECT DISTINCT origerr.* FROM ign_an.origerr origerr WHERE origerr.orid in (320023 320049, 320065)
SELECT DISTINCT remark.* FROM ign_an.remark remark WHERE remark.commid in (64599, 64600, 64617, 64601, 64580, 64581, 64603, 64606, 64608, 64607, 64611, 64615, 64613, 64618, 64619, 64626, 64621, 64623)
SELECT DISTINCT amplitude.* FROM ign_an.amplitude amplitude, ign_an.assoc assoc WHERE amplitude.arid = assoc.arid AND assoc.orid in (320023 320049, 320065)
SELECT s.sta,s.chan,i.ncalib,i.ncalper,s.time,s.endtime
FROM ign_an.sensor s, ign_an.instrument i
WHERE s.inid=i.inid
AND lower(substr(s.chan,1,1)) IN ('b','s','e')
AND lower(substr(s.chan,2,1))='z'
AND s.sta NOT IN ( SELECT sta FROM ign_an.beamaux beamaux )
ORDER BY s.chan
SELECT DISTINCT orid, time, origin.commid FROM ign_an.origin origin, ign_an.event e where origin.evid = e.evid and origin.orid != e.prefor and e.evid in (select evid from ign_an.origin where orid in (320023 320049, 320065))

As you can see, the statement make n selects, and return everything within one row (command groups)

Thanks again for your help

Dv
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top