Click here to Skip to main content
15,868,141 members
Home / Discussions / Database
   

Database

 
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 
GeneralRe: Sql issue.. Pin
<<Tash18>>1-Mar-10 22:44
<<Tash18>>1-Mar-10 22:44 
GeneralRe: Sql issue.. Pin
J4amieC1-Mar-10 23:05
J4amieC1-Mar-10 23:05 
QuestionShould I index this? Pin
Mike6543211-Mar-10 9:22
Mike6543211-Mar-10 9:22 
AnswerRe: Should I index this? Pin
Luc Pattyn1-Mar-10 9:34
sitebuilderLuc Pattyn1-Mar-10 9:34 
GeneralRe: Should I index this? Pin
Mike6543211-Mar-10 9:42
Mike6543211-Mar-10 9:42 
GeneralRe: Should I index this? Pin
David Mujica1-Mar-10 10:20
David Mujica1-Mar-10 10:20 

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.