•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 402,403 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,946 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 955 | Replies: 2
•
•
Join Date: Jun 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I'm in need of some help with 3 tables I have with MSSQL. Is there a way to use a single database query to get the results I'm looking for? (See the bottom for an ideal returned recordset.) Thanks!
TABLE: APPLICATION
APP_ID APP_NM GRP_ID
--------------------------------------
1 Script 1 1
2 Script 2 1
3 Script 3 2
TABLE: STATUS
STAT_ID APP_ID STAT_TM STAT_DSC
---------------------------------------------
1 1 4:00pm OK
2 2 4:00pm OK
3 1 4:15pm OK
4 3 4:00pm FAILED
5 2 4:15pm FAILED
6 3 4:15pm OK
TABLE: GROUPS
GRP_ID GRP_NM
--------------------
1 Group 1
2 Group 2
These tables are related as follows:
APPLICATION.APP_ID <---> STATUS.APP_ID
APPLICATION.GRP_ID <---> GROUPS.GRP_ID
You see, the idea is to tell the database:
Give me all the latest 'status' records for 'Group 1' applications.
The ideal query specifically for "Group 1" is to show the following results:
STAT_ID STAT_TM STAT_DSC APPL_ID APPL_NM GRPS_ID
----------------------------------------------------------------------------
5 4:15pm FAILED 2 Script 2 1
Thanks for any help!
-Michael
TABLE: APPLICATION
APP_ID APP_NM GRP_ID
--------------------------------------
1 Script 1 1
2 Script 2 1
3 Script 3 2
TABLE: STATUS
STAT_ID APP_ID STAT_TM STAT_DSC
---------------------------------------------
1 1 4:00pm OK
2 2 4:00pm OK
3 1 4:15pm OK
4 3 4:00pm FAILED
5 2 4:15pm FAILED
6 3 4:15pm OK
TABLE: GROUPS
GRP_ID GRP_NM
--------------------
1 Group 1
2 Group 2
These tables are related as follows:
APPLICATION.APP_ID <---> STATUS.APP_ID
APPLICATION.GRP_ID <---> GROUPS.GRP_ID
You see, the idea is to tell the database:
Give me all the latest 'status' records for 'Group 1' applications.
The ideal query specifically for "Group 1" is to show the following results:
STAT_ID STAT_TM STAT_DSC APPL_ID APPL_NM GRPS_ID
----------------------------------------------------------------------------
5 4:15pm FAILED 2 Script 2 1
Thanks for any help!
-Michael
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- SQL statement to query user input?? (MS Access and FileMaker Pro)
- Tooltip for ASP database query result (ASP)
- Error Executing Database Query on server (ColdFusion)
- Using PHP to connect to remote MSSQL database (PHP)
- conditional database query (ColdFusion)
- Javascript array from sql query (JSP)
- Database and ASP loops and hierarachal Data (ASP)
Other Threads in the MS SQL Forum
- Previous Thread: cross data please heslp
- Next Thread: Seemingly Simple Issue



Threaded Mode