|
leite333
Starting Member
8 Posts |
Posted - 2011-03-12 : 01:39:47
|
| HiI want some help to create a big query to get a specific result. My tables i am interesting too are:1)E1_Emp001_3 -> Fields: Kwd,Company,Adress_1,City_1,Tel_1,Tel_2,Mobile,Ypol,SinTzirou,KwdPoliti,OnomaPoliti2)E1_Emp016_3->Fields:KwdPelati(same with kwd from E1_Emp001_3),KwdPar,DatePar3)The third Table i dont know if its neccessary itsE1_Emp051_3->Fields:Kwd(same with KwdPoliti),FullName(same with OnomaPoliti from above)The result i wanna get is little complicate:I wanna take for every seller(OnomaPoliti or(FullName) and Kwd(same with KwdPoliti)and CityCustomers with: Kwd,Company,Adress_1,Tel_1,Tel_2,Mobile,Ypol,SinTziroy.Cities maybe the same but with different seller and different customers. The last field i wanna take as a result wich is the most difficult is a field(Mesos) wich will bring as a result counting of days from today now and the last day that E1_Emp016_3.KwdPar was 1 or 3. AS far i have made that query but is not the best:SELECT row_number() OVER (ORDER BY KWDPWLITI, CITY_1) AS Row_No , E1_Emp051_3.FULLNAME, E1_Emp001_3.CITY_1, E1_Emp001_3.KWDPWLITI, E1_Emp001_3.TEL_1, E1_Emp001_3.TEL_2, E1_Emp001_3.COMPANY, E1_Emp001_3.PRYPOL, E1_Emp001_3.SINTZIROU, E1_EMP016_3.KWDPAR, DATEDIFF(DAY,DATEPAR,GETDATE()) AS MESOSFROM E1_Emp001_3, E1_Emp051_3,E1_Emp016_3WHERE E1_Emp051_3 .KWD = E1_Emp001_3.KWDPWLITIPlease help.. |
|