If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-18-08, 03:12
BlueGemini BlueGemini is offline
Registered User
 
Join Date: Jun 2008
Posts: 49
MySQL Help

I have some problems on how to output this...

Here's an example of my table

table1

-------------------------------------------------------
jobid transcode dtestarted startedby
-------------------------------------------------------
0001 AR 2008-06-15 07:42:26 dave
0001 SH 2008-06-18 17:21:10 justine
0002 AR 2008-06-18 08:21:10 dave
0002 SH 2008-06-18 17:30:10 justine
0003 AR 2008-06-18 17:21:10 jonas
0003 SH 2008-06-18 18:21:10 cruz

I must output the number counts of jobid of every person who's transcode is AR and I must display the dtestarted of that certain jobid where the transcode is SH

I did the query like this:

Quote:
select
count(jobid) as `counts`,
startedby,
dtestarted
from table1 where transcode = 'AR'
group by startedby
But I have no idea on how to output the dtestarted of the jobid (where the transcode is SH) along with it...

Last edited by BlueGemini; 06-18-08 at 03:16.
Reply With Quote
  #2 (permalink)  
Old 06-18-08, 07:22
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
I must output the number counts of jobid of every person who's transcode is AR
Code:
SELECT startedby
     , COUNT(jobid) AS `counts`
  FROM table1 
 WHERE transcode = 'AR'
GROUP 
    BY startedby
and I must display the dtestarted of that certain jobid where the transcode is SH
Code:
SELECT row_SH.jobid
     , row_SH.dtestarted
  FROM table1 AS row_AR
INNER
  JOIN table1 AS row_SH
    ON row_SH.jobid = row_AR.jobid
 WHERE row_AR.transcode = 'AR'
   AND row_SH.transcode = 'SH'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-18-08, 07:55
BlueGemini BlueGemini is offline
Registered User
 
Join Date: Jun 2008
Posts: 49
Quote:
Originally Posted by r937
I must output the number counts of jobid of every person who's transcode is AR
Code:
SELECT startedby
     , COUNT(jobid) AS `counts`
  FROM table1 
 WHERE transcode = 'AR'
GROUP 
    BY startedby
and I must display the dtestarted of that certain jobid where the transcode is SH
Code:
SELECT row_SH.jobid
     , row_SH.dtestarted
  FROM table1 AS row_AR
INNER
  JOIN table1 AS row_SH
    ON row_SH.jobid = row_AR.jobid
 WHERE row_AR.transcode = 'AR'
   AND row_SH.transcode = 'SH'
It work! Thank you! Thank you very much!

I really appreciated it.
Reply With Quote
  #4 (permalink)  
Old 06-20-08, 02:46
homer.favenir homer.favenir is offline
Registered User
 
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
its like,you make 2 tables out of 1 table and place it on a variable.
and when you have 2 tables you can now select what fields you need from the source table.
great, nice tricks.

__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On