Click here to Skip to main content
15,886,963 members
Home / Discussions / Database
   

Database

 
QuestionHelp on using Transaction Pin
Saiyed Alam4-Mar-10 5:00
Saiyed Alam4-Mar-10 5:00 
AnswerRe: Help on using Transaction Pin
Not Active4-Mar-10 5:45
mentorNot Active4-Mar-10 5:45 
Questiondesign a database to store an expression tree [modified] Pin
deostroll4-Mar-10 2:06
deostroll4-Mar-10 2:06 
AnswerRe: design a database to store an expression tree Pin
Mschauder5-Mar-10 2:45
Mschauder5-Mar-10 2:45 
QuestionADO.NET Batch Update Pin
MB_KSU3-Mar-10 11:59
MB_KSU3-Mar-10 11:59 
AnswerRe: ADO.NET Batch Update Pin
Mycroft Holmes3-Mar-10 21:32
professionalMycroft Holmes3-Mar-10 21:32 
GeneralRe: ADO.NET Batch Update Pin
MB_KSU4-Mar-10 3:56
MB_KSU4-Mar-10 3:56 
GeneralRe: ADO.NET Batch Update Pin
Mycroft Holmes4-Mar-10 11:14
professionalMycroft Holmes4-Mar-10 11:14 
Questioncalling stored procedure in case statement - Sql Server 2000 Pin
vamsimohan212-Mar-10 23:41
vamsimohan212-Mar-10 23:41 
AnswerRe: calling stored procedure in case statement - Sql Server 2000 Pin
The Man from U.N.C.L.E.3-Mar-10 1:43
The Man from U.N.C.L.E.3-Mar-10 1:43 
AnswerRe: calling stored procedure in case statement - Sql Server 2000 Pin
Pranay Rana3-Mar-10 19:04
professionalPranay Rana3-Mar-10 19:04 
GeneralRe: calling stored procedure in case statement - Sql Server 2000 Pin
Mycroft Holmes3-Mar-10 21:29
professionalMycroft Holmes3-Mar-10 21:29 
AnswerRe: calling stored procedure in case statement - Sql Server 2000 Pin
The Man from U.N.C.L.E.3-Mar-10 22:48
The Man from U.N.C.L.E.3-Mar-10 22:48 
QuestionWhats wrong with SQL statement? Pin
gengel2-Mar-10 19:47
gengel2-Mar-10 19:47 
Table 1 (UNITS)
ScanID ScanCount OrderID SerialNo ScanStatus ProductionNo
1981 1294 2 147639NZ301774 SHIPPED 10007627289
There are 1300 SerialNo's for ProductionNo That will end with status 'SHIPPED'

Table 2 (Unit_Logs)
LogID SerialNo ProductionNo Old_Status New_Status
1 147639NZ301774 10007627289 PACKED SHIPPED
There will be 1300 records with status changes from PACKED to SHIPPED

Needed RESULT:
ProductionNo PACKED SHIPPED
10007627289 1300 1300

This is what I have tried:
SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED,
COUNT(UNIT_Logs.SerialNo) AS PACKED
FROM UNITS JOIN UNIT_Logs
ON UNITS.ProductionNo = UNIT_Logs.ProductionNo
GROUP BY UNITS.ProductionNo, UNITS.ScanStatus, UNIT_Logs.Old_Status
HAVING (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED')

I added 1 log entry to the table, but the query returns nothing.
Think might need sub query, but not sure where to go from here.
AnswerRe: Whats wrong with SQL statement? [modified] Pin
Jörgen Andersson2-Mar-10 21:48
professionalJörgen Andersson2-Mar-10 21:48 
AnswerRe: Whats wrong with SQL statement? Pin
i.j.russell2-Mar-10 22:04
i.j.russell2-Mar-10 22:04 
GeneralRe: Whats wrong with SQL statement? Pin
gengel2-Mar-10 22:46
gengel2-Mar-10 22:46 
GeneralRe: Whats wrong with SQL statement? [modified] Pin
i.j.russell2-Mar-10 23:35
i.j.russell2-Mar-10 23:35 
GeneralRe: Whats wrong with SQL statement? Pin
gengel3-Mar-10 1:14
gengel3-Mar-10 1:14 
GeneralRe: Whats wrong with SQL statement? Pin
gengel3-Mar-10 1:17
gengel3-Mar-10 1:17 
GeneralRe: Whats wrong with SQL statement? Pin
i.j.russell3-Mar-10 2:00
i.j.russell3-Mar-10 2:00 
QuestionPermission sp_rename Pin
Clas Andersson2-Mar-10 7:23
Clas Andersson2-Mar-10 7:23 
AnswerRe: Permission sp_rename Pin
Mycroft Holmes2-Mar-10 10:52
professionalMycroft Holmes2-Mar-10 10:52 
QuestionSql issue.. Pin
<<Tash18>>1-Mar-10 21:05
<<Tash18>>1-Mar-10 21:05 
AnswerRe: Sql issue.. Pin
J4amieC1-Mar-10 21:15
J4amieC1-Mar-10 21:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.