Click here to Skip to main content
15,899,026 members
Home / Discussions / Database
   

Database

 
Questionhow can a get top each event in my related table Pin
mhd.sbt26-Mar-13 7:07
mhd.sbt26-Mar-13 7:07 
AnswerRe: how can a get top each event in my related table Pin
Corporal Agarn26-Mar-13 8:57
professionalCorporal Agarn26-Mar-13 8:57 
GeneralRe: how can a get top each event in my related table Pin
mhd.sbt27-Mar-13 0:59
mhd.sbt27-Mar-13 0:59 
AnswerRe: how can a get top each event in my related table Pin
Mycroft Holmes26-Mar-13 13:08
professionalMycroft Holmes26-Mar-13 13:08 
AnswerRe: how can a get top each event in my related table Pin
EralperYilmaz1-Apr-13 1:20
EralperYilmaz1-Apr-13 1:20 
QuestionDatabase Deployment/Version updates in unison with source code Pin
dexterama26-Mar-13 6:55
professionaldexterama26-Mar-13 6:55 
AnswerRe: Database Deployment/Version updates in unison with source code Pin
Mycroft Holmes26-Mar-13 13:05
professionalMycroft Holmes26-Mar-13 13:05 
Questioncertain rows to column Pin
Richard.Berry10025-Mar-13 18:26
Richard.Berry10025-Mar-13 18:26 
Hi
Using SQL Server 2008 R2. I have a stock table, with the following fields: warehouse, product, long_description, physical_qty.

All products exist in warehouse '01'. Some of the products exist in warehouse '03' Faulty (or NG) goods get transferred to warehouse 03.

I need a query to show distinct(product), long_description, physical_qty (for warehouse 01), physical_qty (for warehouse 03)


Example data:
warehouse product long_description physical_qty
01 00-00001 Item 1 100
03 00-00001 Item 1 5
01 00-00002 Item 2 200

Desired Result:
Product Description Stock_Qty NG_Qty
00-00001 Item 1 100 5
00-00002 Item 2 200

I have tried this, but don't get distinct products (i.e. Item 1 appears in two rows)

SQL
Select distinct(product), long_description, case warehouse when '01' then physical_qty else 0 end as [Stock_Qty], case warehouse when '03' then physical_qty else 0 end as [NG_Qty] from vektron2.scheme.stockm group by product, warehouse, long_description, physical_qty order by product

AnswerRe: certain rows to column Pin
Mycroft Holmes26-Mar-13 1:14
professionalMycroft Holmes26-Mar-13 1:14 
GeneralRe: certain rows to column Pin
Richard.Berry10027-Mar-13 2:30
Richard.Berry10027-Mar-13 2:30 
QuestionSearch in all tables for a given where condition Pin
Member 313707825-Mar-13 4:51
Member 313707825-Mar-13 4:51 
AnswerRe: Search in all tables for a given where condition Pin
Chris Quinn25-Mar-13 5:00
Chris Quinn25-Mar-13 5:00 
Questionmy sql code to sql Pin
alexpandy125-Mar-13 0:30
alexpandy125-Mar-13 0:30 
AnswerRe: my sql code to sql Pin
Marco Bertschi25-Mar-13 1:52
protectorMarco Bertschi25-Mar-13 1:52 
AnswerRe: my sql code to sql Pin
Bernhard Hiller25-Mar-13 2:08
Bernhard Hiller25-Mar-13 2:08 
QuestionSQL SERVER R2 set mode Pin
kornkimhour24-Mar-13 17:44
kornkimhour24-Mar-13 17:44 
AnswerRe: SQL SERVER R2 set mode Pin
Mycroft Holmes24-Mar-13 19:17
professionalMycroft Holmes24-Mar-13 19:17 
AnswerRe: SQL SERVER R2 set mode Pin
Sandeep Mewara24-Mar-13 19:23
mveSandeep Mewara24-Mar-13 19:23 
Questionwhat is the database connectivity Pin
mmmickyyy24-Mar-13 3:35
mmmickyyy24-Mar-13 3:35 
AnswerRe: what is the database connectivity Pin
Sandeep Mewara24-Mar-13 5:45
mveSandeep Mewara24-Mar-13 5:45 
AnswerRe: what is the database connectivity Pin
Maciej Los24-Mar-13 7:26
mveMaciej Los24-Mar-13 7:26 
Questiondisplay booked dates in red color in calender Pin
Member 870181324-Mar-13 3:07
Member 870181324-Mar-13 3:07 
AnswerRe: display booked dates in red color in calender Pin
Pallavi Waikar24-Mar-13 4:34
Pallavi Waikar24-Mar-13 4:34 
GeneralRe: display booked dates in red color in calender Pin
Member 870181325-Mar-13 7:58
Member 870181325-Mar-13 7:58 
GeneralRe: display booked dates in red color in calender Pin
Pallavi Waikar25-Mar-13 17:50
Pallavi Waikar25-Mar-13 17:50 

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.