Click here to Skip to main content
15,888,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,

Hope you all are doing great. I am stuck at a problem. The problem is that i have a SQL table and it hase around 10 columns but only 3 are useful in this scenario ( CardsNumber, MerchantID and Date).
Lets focus on CardNumber and Merchant for a moment.
Lets assume that i have following data in the table.
CardNumber     MerchantID     date
123            abc            1160101
123            abc            1160103
234            xyz            1160105
645            abc            1160301
123            xyz            1160102
345            abc            1160110
345            xyz            1160310

Note:
In above data, Date is in float and in format 1yymmdd.

I want to apply a few filters on above data.
In my application on frontend i will be entering cardNumber which are entered dynamically(rows can be added at runtime if there are more than one card number) and Date range (StartDate and EndDate). Now lets assume that on frontend i am entering 3 cards (123, 345 and 645) and date range from 1st Jan 2016 till 1st March 2016. When the submit button is clicked it should retrieve information based on following filters.
1. Fetch data that have different cards and same Merchants.
In the above dataset the different cards on same merchant are
123 abc 1160101
645 abc 1160301
123 xyz 1160102
345 xyz 1160110

2. Fetch only those records which have datedifference of 10 days.
In above dataset only following records should be fetched
123 xyz 1160102
345 xyz 1160110

So this is how the filteration should work.
If there is anything that is not cleared, i would be more than happy to clear it.

Looking forward to your usual help.

Thanks.

What I have tried:

I have tried many things but unable to find a relavent solution
Posted
Updated 13-Dec-16 20:37pm
v2
Comments
jamuro77 14-Dec-16 2:41am    
I don't understand well your results. What is obtained date in tour first point? The minimum date? And with regard to second point, is "date difference" set with origin in "initial date"?
Faran Saleem 14-Dec-16 3:09am    
Leave out date.. that is not ao important. I just want to fetch the results with different cards on same merchant.
For example--> if i have 3 cards and they are swiped on 2 different merchants i-e 123 card swiped on abc merchant,345 on abc and 645 on xyz .
So in above scenario i would like to fetch results which have different cards on same merchants. Which would be 123 on abc and 345 on abc

1 solution

Well i won't spoil the fun for you to find out how to write that sql querry correctly but i tell something for part 1.
There is an IN(no1,no2,no3...) Statement in SQL that you can use for your cards. Also there is an BETWEEN Statement that could be usefull for your Dates.
Combining those 2 correctly in the WHERE part of your Querry shall solve your 1st filter.

For the 2nd, i really don't understand what you mean.
 
Share this answer
 
Comments
Faran Saleem 14-Dec-16 3:05am    
I know wha t these keywords do.. but the question is how can i select different cards on same merchants..?
HobbyProggy 14-Dec-16 3:25am    
If you select by cards it should automatically list up the same merchant multiple times as long as you don't group by merchant.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900