Condition select queries

benedictine191

Registered User.
Local time
Today, 15:46
Joined
Dec 1, 2015
Messages
12
Hi, anyone can help me?
i have a problem,
do anyone know a queries to split the condition...
in example

select (a from t1 where t1.category = 'sell out'), (b from t1 where category = 'sell in')
from t1?

here is the screenshot of each table,
first is [raw dealer] (contains md,channel,imei,sold to)
second is [export] (contains category,imei,sold_to)

if i join this two table :
based on [raw dealer].imei = [export].imei

it will result all the data,
what i want, is there a way to find the field each stage?
stage 1 : I want to check the "IMEI" in the category "production",
stage 2 : I check the "imei" in the category "sold out"..


sorry for troubling you by bad english
 

Attachments

  • 2015-12-07_181026.png
    2015-12-07_181026.png
    7.1 KB · Views: 88
  • 2015-12-07_181546.png
    2015-12-07_181546.png
    18.4 KB · Views: 89
Can you demonstrate with data what you expect your query to return?

You've already provided sample data from your source tables (the screenshots), now based on the data in those show me what you expect your query to return. Be sure to include field names.
 
Further to plog's post, could you post a jpg/png of your tables and relationships (relationships window)?
 
Further to plog's post, could you post a jpg/png of your tables and relationships (relationships window)?

[quote = plog]Can you demonstrate with data what you expect your query to return?

You've already provided sample data from your source tables (the screenshots), now based on the data in those show me what you expect your query to return. Be sure to include field names.[/quote]

I tried to attach the relations of the table, the result of my query based on MD = "depo tam sby"...and i got the 83 records, each of them have duplicate IMEI result, but the duplicate is because the category, one imei has category sell in, sell out and production...

what i want is i just took all the imei record without duplicate, so I tried to copy the IMEI records to excel file and remove the duplicates, it count 33 (exactly as what I want)..

the condition provided to result what I want is :

1st. I will output the result like in the query
2nd. I took the IMEI based on :
a. if the IMEI only has 1 record, it will counted.
b. if the IMEI has more than 1 records (in the sell out category, sell in category, sell thru category), it will count only the sell out one.
 

Attachments

  • relationship.png
    relationship.png
    9.1 KB · Views: 78
  • Result.png
    Result.png
    58.7 KB · Views: 75
  • Remove Duplicate.png
    Remove Duplicate.png
    3 KB · Views: 85
  • Raw Data.zip
    Raw Data.zip
    957.6 KB · Views: 216
You've now confused me with too much data.

Please give me 2 sets of data:

A. Starting sample data. Show me some sample data from all applicable tables. Include table and field names and enough data to cover all cases.

B. Expected results based on A. Show me what data you want returned from your query when you feed it the data in A.
 

Users who are viewing this thread

Back
Top Bottom